ImageGear .NET - Updated
Loading from a Database
User Guide > How to Work with... > Common Operations > Viewing > Viewing Using ASP.NET > Loading from a Database

In addition to loading a document from file (see the ASP.NET Application tutorial), a document can be loaded from a database.

  1. In web.config:
    1. Add the connection string for your database. Set %DATABASE_NAME% to your database name.
       
      Copy Code
      <connectionStrings>
      
         <add name="SqlImageProviderConnection" connectionString="Data
           Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\%DATABASE_NAME%;Integrated Security=True;User Instance=True" />
      
      </connectionStrings>
      
    2. Add the database to the list of providers (the code below is one very long line):
       
      Copy Code
          <add name="SqlImageDataProvider"
      type="ImageGear.Web.DataProviders.SqlImageDataProvider,ImageGear23.Web.Services" connectionStringName="SqlImageProviderConnection"
      sqlCommand="SELECT ImageData FROM dbo.ImageStore WHERE [Image_key] = @Image_key" sqlCommandType="Text" sqlImageDataField="ImageData"
      sqlParameter="@Image_key" paramKeySqlDbType="UniqueIdentifier" paramKeyLength="36" cachingEnable="false" sqlCacheDependencyNeeded="false"
      initSqlCacheDependency="false" maxImageSizeToCache="512" cachingTimeLimit="5" sqlArtReadCommand="SELECT Annotations FROM dbo.ImageStore
      WHERE [Image_key] = @Image_key" sqlArtReadCommandType="Text" sqlArtUpdateCommand="UPDATE dbo.ImageStore SET Annotations = @Annotations
      WHERE [Image_key] = @Image_key" sqlArtUpdateCommandType="Text" sqlArtDataField="Annotations" sqlArtParameter="@Annotations" />
      
  2. In Default.aspx, use openPage with the database provider:
     
    Copy Code
    _ctrlView.openPage({ documentIdentifier: 'SqlImageDataProvider:6b29f53a-1e1b-446b-9b3b-9d234452f3e2', pageNumber: 1, viewFitType:
    ImageGear.Web.UI.FitType.ActualSize });