In addition to loading a document from a file, a document can be loaded from a database.
- In web.config:
- 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>
|
- 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,ImageGear.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" />
|
- 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 });
|