The following attributes may be set within the web.config to specify your built-in SqlImageDataProvider:
|
Familiarity and experience working with databases is expected for the use and implementation of database based Image Data Providers. If you have any general database related questions or any other questions related to database engine and its behavior used at your site, then please consult your Database Administrator. |
- name - (Required) Specifies the name of the image data provider.
|
For the built-in SQL image data provider, the name must be specified as "SqlImageDataProvider". If you use the built in provider, and do not provide this name, your images will not display. The name coincides with the name of the class. When you write your own custom data providers, this name can be any string that you give in your code. Refer to the "RadiologyOfficeSample" sample for an example of how to write a custom image data provider. |
- type - (Required) Specifies the Image Data Provider class and the assembly to which it belongs. (For the built-in provider, the assembly is ImageGear21.Web.Services).
|
If your provider is a class in your application (in App Code), then the assembly name is not required. |
- connectionStringName - (Required) Specifies the connection name for the database. Dependent on your database and the database server. (This will require a change depending on your environment.)
- sqlCommand - (Required) A Sql query command or a stored procedure that when executed returns a DocumentIdentifier. This attribute value can be edited to suit your database.
|
If you edit the query, using either the Visual Studio or the Sql Server Management Studio, make sure that it executes correctly and returns the expected results. |
- sqlParameter - (Required) Represents the column / data field being searched in the query.
|
For the built-in SqlImageDataProvider, we recommend that this column / data field contain unique values. (For example, in the WebSqlSample, the "Image_key" and "id" columns/fields contain unique values. Either of these could be used.) The sqlParameter does not have to be a primary key or foreign key. You may choose any column for the query in your command. However, if your query results in multiple row fetches, only the first row will be processed. Other rows will be ignored. |
- sqlCommandType - (Required) Specifies a Text (syntax "Text") command or a stored procedure (syntax "StoredProcedure").
- sqlInsetCommand – (new in v20 for upload) A Sql Insert command or a stored procedure that when executed inserts an image document or document name into the data base.
- sqlInsertCommandType – (new in v20 for upload) Specifies a Text (syntax "Text") command or a stored procedure (syntax "StoredProcedure").
- sqlImageDataParameter – (new in v20 for upload) Represents the value parameter identifier used in the insert command for the image data field or column.
- sqlImageDataFieldBlob - (Required) Indicates whether the image data stored in the database (see attribute 'sqlImageDataField') is in a BLOB format. This attribute takes the value "true or "false" (note case sensitivity). The default value is "true", meaning the image data is stored in the database in a "BLOB" format in the data field specified by the attribute 'sqlImageDataField'. A value of 'false' expects image file name stored in the field specified in the 'sqlImageDataField' attribute.
- sqlImageDataField - (Required) Specifies the name of the column that contains the actual image data when the images are stored in a 'BLOB' format, or contains the file path name in the scenarios where the image data is stored in files.
|
For the built in provider, the 'BLOB" format image data storage requires Sql data type data to be a varbinary(max) or 'image' Sql data type column SQL Server 2005). We recommend that you use varbinary(max) since Microsoft will eventually deprecate 'image' Sql data type. If you use other databases, then this column data type must be a binary Blob equivalent. For image scenarios where image data is stored in files, the Sql data type column can be Text. |
- paramKeyLength - Specifies the length of the Key (sqlParameter) used to query the database for image retrieval. This parameter is useful to prevent SQL injection if you are using a stored procedure in your query. For a detailed description of SQL Injection, refer to the article on MSDN:
-
- paramKeySqlDbType - Specifies the SQL Database type of the query parameter (sqlParameter). This attribute is used in conjunction with the above attribute (paramKeyLength) to prevent SQL injection attacks.
|
Some database engines like SQL Server Express ignore this feature. Please consult your DBA for advice. |
- cachingEnable - (Required) Indicates whether caching is enabled. This attribute is a boolean and takes a value of "true" or "false" (note the case sensitivity).
- A value of "false" will disable all caching. (Default value)
- If cachingEnable is set to "true" and the attribute "sqlCacheDependencyNeeded" (described below) is set to "false", then only ordinary data caching will be performed (no Sql dependency caching will occur).
- If cachingEnable is set to "true" and the attribute "sqlCacheDependencyNeeded" is set to "true", then both ordinary data caching and Sql dependency caching will occur.
|
The ordinary cache will never cache annotations data. |
- sqlCacheDependencyNeeded - Indicates whether SQL dependency will be used for caching. This attribute has a boolean value of "true" or "false" (note the case sensitivity).
- A value of "false" indicates that SQL dependency will not be used for caching. (Default value)
- A value of "true" indicates that SQL dependency will be used for caching.
|
The default SQL provider supports two types of caching: ordinary data caching and SQL dependency caching. SQL dependency caching is recommended only if your image database is static. If your image database is being constantly updated, then you want to make sure that you are not retrieving outdated images, and therefore SQL dependency caching is not recommended. |
|
Your database must be configured for Sql dependency prior to use by performing a one-time setup procedure. |
See Setting Up SQL Server 2005 and SQL Server 2008 Cache Dependencies.
- initSqlCacheDependency - Indicates whether SqlCacheDependency should be initialized by the image data provider. This attribute has a boolean value of "true" or "false".
- A value of "false" indicates that SqlCacheDependency should not be initialized by the image data provider. (Default value).
- A value of "true" indicates that SqlCacheDependency should be initialized by the image data provider. A value of "true" has meaning only if cachingEnable and sqlCacheDependencyNeeded are both also set to "true".
|
SQL dependency requires one time initialization. If this initialization has already occurred in your application, then the initSqlCacheDependency attribute should be set to false. See the example below for information on how to perform the initialization in your application. |
Set initSqlCacheDependency attribute to "false" and call the method below before you access any data from the database:
C# |
Copy Code |
System.Data.SqlClient.SqlDependency.Start(). |
The method must be called before the first query is executed. Some prefer to put it in the global.asax file.
C# |
Copy Code |
void Application_Start(object sender, EventArgs e)
{
System.Data.SqlClient.SqlDependency.Start(ConfigurationManager.ConnectionStrings["conn"].ConnectionString);
} |
- maxImageSizeToCache -Allows you to put an upper limit on the size of the image that can be cached using ordinary cache (not Sql-dependency cache). When deciding on the value, bear in mind the amount of memory your system has. A larger value on infrequently used images will unnecessarily use up the memory for cache. This value is in kilobytes. The default value is 512K.
- cachingTimeLimit - Represents the amount of time in minutes that the image is to remain in the ordinary cache (not Sql-dependency cache). Upon remaining in the cache for the amount of time specified, the system flushes the cached image. The default value is 5 minutes.
- storageRootPath - (Required when image data is stored in files) Specifies the root folder path where the image files are stored. This can be changed to suit your image storage system. To indicate that the folder is relative to the web application folder, prepend the path with the '~' character (example: "~/viewerImages/").