ASP.NET Syntax ASP.NET Syntax for Web Controls
Represents a data source control that works with Microsoft Access databases.
Declarative Syntax
<asp:AccessDataSource
CacheDuration = "string | Infinite"
CacheExpirationPolicy = "Absolute | Sliding"
CacheKeyDependency = "string"
CancelSelectOnNullParameter = "True | False"
ConflictDetection = "OverwriteChanges | CompareAllValues"
DataFile = "uri"
DataSourceMode = "DataReader | DataSet"
DeleteCommand = "string"
DeleteCommandType = "Text | StoredProcedure"
EnableCaching = "True | False"
EnableTheming = "True | False"
EnableViewState = "True | False"
FilterExpression = "string"
ID = "string"
InsertCommand = "string"
InsertCommandType = "Text | StoredProcedure"
OldValuesParameterFormatString = "string"
OnDataBinding = "DataBinding event handler"
OnDeleted = "Deleted event handler"
OnDeleting = "Deleting event handler"
OnDisposed = "Disposed event handler"
OnFiltering = "Filtering event handler"
OnInit = "Init event handler"
OnInserted = "Inserted event handler"
OnInserting = "Inserting event handler"
OnLoad = "Load event handler"
OnPreRender = "PreRender event handler"
OnSelected = "Selected event handler"
OnSelecting = "Selecting event handler"
OnUnload = "Unload event handler"
OnUpdated = "Updated event handler"
OnUpdating = "Updating event handler"
runat = "server"
SelectCommand = "string"
SelectCommandType = "Text | StoredProcedure"
SkinID = "string"
SortParameterName = "string"
UpdateCommand = "string"
UpdateCommandType = "Text | StoredProcedure"
Visible = "True | False"
>
<DeleteParameters>
<asp:ControlParameter
ControlID = "string"
ConvertEmptyStringToNull = "True | False"
DefaultValue = "string"
Direction = "Input | Output | InputOutput |
ReturnValue"
Name = "string"
PropertyName = "string"
Size = integer
Type = "Empty | Object | DBNull | Boolean | Char | SByte |
Byte | Int16 | UInt16 | Int32 | UInt32 | Int64 | UInt64 |
Single | Double | Decimal | DateTime | String"
/>
<asp:CookieParameter
ConvertEmptyStringToNull = "True | False"
CookieName = "string"
DefaultValue = "string"
Direction = "Input | Output | InputOutput |
ReturnValue"
Name = "string"
Size = integer
Type = "Empty | Object | DBNull | Boolean | Char | SByte |
Byte | Int16 | UInt16 | Int32 | UInt32 | Int64 | UInt64 |
Single | Double | Decimal | DateTime | String"
/>
<asp:FormParameter
ConvertEmptyStringToNull = "True | False"
DefaultValue = "string"
Direction = "Input | Output | InputOutput | ReturnValue"
FormField = "string"
Name = "string"
Size = integer
Type = "Empty | Object | DBNull | Boolean | Char | SByte |
Byte | Int16 | UInt16 | Int32 | UInt32 | Int64 | UInt64 |
Single | Double | Decimal | DateTime | String"
/>
<asp:Parameter
ConvertEmptyStringToNull = "True | False"
DefaultValue = "string"
Direction = "Input | Output | InputOutput | ReturnValue"
Name = "string"
Size = integer
Type = "Empty | Object | DBNull | Boolean | Char | SByte |
Byte | Int16 | UInt16 | Int32 | UInt32 | Int64 | UInt64 |
Single |Double | Decimal | DateTime | String"
/>
<asp:ProfileParameter
ConvertEmptyStringToNull = "True | False"
DefaultValue = "string"
Direction = "Input | Output | InputOutput | ReturnValue"
Name = "string"
PropertyName = "string"
Size = integer
Type = "Empty | Object | DBNull | Boolean | Char | SByte |
Byte | Int16 | UInt16 | Int32 | UInt32 | Int64 | UInt64 |
Single | Double | Decimal | DateTime | String"
/>
<asp:QueryStringParameter
ConvertEmptyStringToNull = "True | False"
DefaultValue = "string"
Direction = "Input | Output | InputOutput | ReturnValue"
Name = "string"
QueryStringField = "string"
Size = integer
Type = "Empty | Object | DBNull | Boolean | Char | SByte |
Byte | Int16 | UInt16 | Int32 | UInt32 | Int64 | UInt64 |
Single | Double | Decimal | DateTime | String"
/>
<asp:SessionParameter
ConvertEmptyStringToNull = "True | False"
DefaultValue = "string"
Direction = "Input | Output | InputOutput | ReturnValue"
Name = "string"
SessionField = "string"
Size = integer
Type = "Empty | Object | DBNull | Boolean | Char | SByte |
Byte | Int16 | UInt16 | Int32 | UInt32 | Int64 | UInt64 |
Single | Double | Decimal | DateTime | String"
/>
</DeleteParameters>
<FilterParameters>
<asp:ControlParameter
ControlID = "string"
ConvertEmptyStringToNull = "True | False"
DefaultValue = "string"
Direction = "Input | Output | InputOutput | ReturnValue"
Name = "string"
PropertyName = "string"
Size = integer
Type = "Empty | Object | DBNull | Boolean | Char | SByte |
Byte | Int16 | UInt16 | Int32 | UInt32 | Int64 | UInt64 |
Single | Double | Decimal | DateTime | String"
/>
<asp:CookieParameter
ConvertEmptyStringToNull = "True | False"
CookieName = "string"
DefaultValue = "string"
Direction = "Input | Output | InputOutput | ReturnValue"
Name = "string"
Size = integer
Type = "Empty | Object | DBNull | Boolean | Char | SByte |
Byte | Int16 | UInt16 | Int32 | UInt32 | Int64 | UInt64 |
Single | Double | Decimal | DateTime | String"
/>
<asp:FormParameter
ConvertEmptyStringToNull = "True | False"
DefaultValue = "string"
Direction = "Input | Output | InputOutput | ReturnValue"
FormField = "string"
Name = "string"
Size = integer
Type = "Empty | Object | DBNull | Boolean | Char | SByte |
Byte | Int16 | UInt16 | Int32 | UInt32 | Int64 | UInt64 |
Single | Double | Decimal | DateTime | String"
/>
<asp:Parameter
ConvertEmptyStringToNull = "True | False"
DefaultValue = "string"
Direction = "Input | Output | InputOutput | ReturnValue"
Name = "string"
Size = integer
Type = "Empty | Object | DBNull | Boolean | Char | SByte |
Byte | Int16 | UInt16 | Int32 | UInt32 | Int64 | UInt64 |
Single | Double | Decimal | DateTime | String"
/>
<asp:ProfileParameter
ConvertEmptyStringToNull = "True | False"
DefaultValue = "string"
Direction = "Input | Output | InputOutput | ReturnValue"
Name = "string"
PropertyName = "string"
Size = integer
Type = "Empty | Object | DBNull | Boolean | Char | SByte |
Byte | Int16 | UInt16 | Int32 | UInt32 | Int64 | UInt64 |
Single | Double | Decimal | DateTime | String"
/>
<asp:QueryStringParameter
ConvertEmptyStringToNull = "True | False"
DefaultValue = "string"
Direction = "Input | Output | InputOutput | ReturnValue"
Name = "string"
QueryStringField = "string"
Size = integer
Type = "Empty | Object | DBNull | Boolean | Char | SByte |
Byte | Int16 | UInt16 | Int32 | UInt32 | Int64 | UInt64 |
Single | Double | Decimal | DateTime | String"
/>
<asp:SessionParameter
ConvertEmptyStringToNull = "True | False"
DefaultValue = "string"
Direction = "Input | Output | InputOutput | ReturnValue"
Name = "string"
SessionField = "string"
Size = integer
Type = "Empty | Object | DBNull | Boolean | Char | SByte |
Byte | Int16 | UInt16 | Int32 | UInt32 | Int64 | UInt64 |
Single | Double | Decimal | DateTime | String"
/>
</FilterParameters>
<InsertParameters>
<asp:ControlParameter
ControlID = "string"
ConvertEmptyStringToNull = "True | False"
DefaultValue = "string"
Direction = "Input | Output | InputOutput | ReturnValue"
Name = "string"
PropertyName = "string"
Size = integer
Type = "Empty | Object | DBNull | Boolean | Char | SByte |
Byte | Int16 | UInt16 | Int32 | UInt32 | Int64 | UInt64 |
Single | Double | Decimal | DateTime | String"
/>
<asp:CookieParameter
ConvertEmptyStringToNull = "True | False"
CookieName = "string"
DefaultValue = "string"
Direction = "Input | Output | InputOutput | ReturnValue"
Name = "string"
Size = integer
Type = "Empty | Object | DBNull | Boolean | Char | SByte |
Byte | Int16 | UInt16 | Int32 | UInt32 | Int64 | UInt64 |
Single | Double | Decimal | DateTime | String"
/>
<asp:FormParameter
ConvertEmptyStringToNull = "True | False"
DefaultValue = "string"
Direction = "Input | Output | InputOutput | ReturnValue"
FormField = "string"
Name = "string"
Size = integer
Type = "Empty | Object | DBNull | Boolean | Char | SByte |
Byte | Int16 | UInt16 | Int32 | UInt32 | Int64 | UInt64 |
Single | Double | Decimal | DateTime | String"
/>
<asp:Parameter
ConvertEmptyStringToNull = "True | False"
DefaultValue = "string"
Direction = "Input | Output | InputOutput | ReturnValue"
Name = "string"
Size = integer
Type = "Empty | Object | DBNull | Boolean | Char | SByte |
Byte | Int16 | UInt16 | Int32 | UInt32 | Int64 | UInt64 |
Single | Double | Decimal | DateTime | String"
/>
<asp:ProfileParameter
ConvertEmptyStringToNull = "True | False"
DefaultValue = "string"
Direction = "Input | Output | InputOutput | ReturnValue"
Name = "string"
PropertyName = "string"
Size = integer
Type = "Empty | Object | DBNull | Boolean | Char | SByte |
Byte | Int16 | UInt16 | Int32 | UInt32 | Int64 | UInt64 |
Single | Double | Decimal | DateTime | String"
/>
<asp:QueryStringParameter
ConvertEmptyStringToNull = "True | False"
DefaultValue = "string"
Direction = "Input | Output | InputOutput | ReturnValue"
Name = "string"
QueryStringField = "string"
Size = integer
Type = "Empty | Object | DBNull | Boolean | Char | SByte |
Byte | Int16 | UInt16 | Int32 | UInt32 | Int64 | UInt64 |
Single | Double | Decimal | DateTime | String"
/>
<asp:SessionParameter
ConvertEmptyStringToNull = "True | False"
DefaultValue = "string"
Direction = "Input | Output | InputOutput | ReturnValue"
Name = "string"
SessionField = "string"
Size = integer
Type = "Empty | Object | DBNull | Boolean | Char | SByte |
Byte | Int16 | UInt16 | Int32 | UInt32 | Int64 | UInt64 |
Single | Double | Decimal | DateTime | String"
/>
</InsertParameters>
<SelectParameters>
<asp:ControlParameter
ControlID = "string"
ConvertEmptyStringToNull = "True | False"
DefaultValue = "string"
Direction = "Input | Output | InputOutput | ReturnValue"
Name = "string"
PropertyName = "string"
Size = integer
Type = "Empty | Object | DBNull | Boolean | Char | SByte |
Byte | Int16 | UInt16 | Int32 | UInt32 | Int64 | UInt64 |
Single | Double | Decimal | DateTime | String"
/>
<asp:CookieParameter
ConvertEmptyStringToNull = "True | False"
CookieName = "string"
DefaultValue = "string"
Direction = "Input | Output | InputOutput | ReturnValue"
Name = "string"
Size = integer
Type = "Empty | Object | DBNull | Boolean | Char | SByte |
Byte | Int16 | UInt16 | Int32 | UInt32 | Int64 | UInt64 |
Single | Double | Decimal | DateTime | String"
/>
<asp:FormParameter
ConvertEmptyStringToNull = "True | False"
DefaultValue = "string"
Direction = "Input | Output | InputOutput | ReturnValue"
FormField = "string"
Name = "string"
Size = integer
Type = "Empty | Object | DBNull | Boolean | Char | SByte |
Byte | Int16 | UInt16 | Int32 | UInt32 | Int64 | UInt64 |
Single | Double | Decimal | DateTime | String"
/>
<asp:Parameter
ConvertEmptyStringToNull = "True | False"
DefaultValue = "string"
Direction = "Input | Output | InputOutput | ReturnValue"
Name = "string"
Size = integer
Type = "Empty | Object | DBNull | Boolean | Char | SByte |
Byte | Int16 | UInt16 | Int32 | UInt32 | Int64 | UInt64 |
Single | Double | Decimal | DateTime | String"
/>
<asp:ProfileParameter
ConvertEmptyStringToNull = "True | False"
DefaultValue = "string"
Direction = "Input | Output | InputOutput | ReturnValue"
Name = "string"
PropertyName = "string"
Size = integer
Type = "Empty | Object | DBNull | Boolean | Char | SByte |
Byte | Int16 | UInt16 | Int32 | UInt32 | Int64 | UInt64 |
Single | Double | Decimal | DateTime | String"
/>
<asp:QueryStringParameter
ConvertEmptyStringToNull = "True | False"
DefaultValue = "string"
Direction = "Input | Output | InputOutput | ReturnValue"
Name = "string"
QueryStringField = "string"
Size = integer
Type = "Empty | Object | DBNull | Boolean | Char | SByte |
Byte | Int16 | UInt16 | Int32 | UInt32 | Int64 | UInt64 |
Single | Double | Decimal | DateTime | String"
/>
<asp:SessionParameter
ConvertEmptyStringToNull = "True | False"
DefaultValue = "string"
Direction = "Input | Output | InputOutput | ReturnValue"
Name = "string"
SessionField = "string"
Size = integer
Type = "Empty | Object | DBNull | Boolean | Char | SByte |
Byte | Int16 | UInt16 | Int32 | UInt32 | Int64 | UInt64 |
Single | Double | Decimal | DateTime | String"
/>
</SelectParameters>
<UpdateParameters>
<asp:ControlParameter
ControlID = "string"
ConvertEmptyStringToNull = "True | False"
DefaultValue = "string"
Direction = "Input | Output | InputOutput | ReturnValue"
Name = "string"
PropertyName = "string"
Size = integer
Type = "Empty | Object | DBNull | Boolean | Char | SByte |
Byte | Int16 | UInt16 | Int32 | UInt32 | Int64 | UInt64 |
Single | Double | Decimal | DateTime | String"
/>
<asp:CookieParameter
ConvertEmptyStringToNull = "True | False"
CookieName = "string"
DefaultValue = "string"
Direction = "Input | Output | InputOutput | ReturnValue"
Name = "string"
Size = integer
Type = "Empty | Object | DBNull | Boolean | Char | SByte |
Byte | Int16 | UInt16 | Int32 | UInt32 | Int64 | UInt64 |
Single | Double | Decimal | DateTime | String"
/>
<asp:FormParameter
ConvertEmptyStringToNull = "True | False"
DefaultValue = "string"
Direction = "Input | Output | InputOutput | ReturnValue"
FormField = "string"
Name = "string"
Size = integer
Type = "Empty | Object | DBNull | Boolean | Char | SByte |
Byte | Int16 | UInt16 | Int32 | UInt32 | Int64 | UInt64 |
Single | Double | Decimal | DateTime | String"
/>
<asp:Parameter
ConvertEmptyStringToNull = "True | False"
DefaultValue = "string"
Direction = "Input | Output | InputOutput | ReturnValue"
Name = "string"
Size = integer
Type = "Empty | Object | DBNull | Boolean | Char | SByte |
Byte | Int16 | UInt16 | Int32 | UInt32 | Int64 | UInt64 |
Single | Double | Decimal | DateTime | String"
/>
<asp:ProfileParameter
ConvertEmptyStringToNull = "True | False"
DefaultValue = "string"
Direction = "Input | Output | InputOutput | ReturnValue"
Name = "string"
PropertyName = "string"
Size = integer
Type = "Empty | Object | DBNull | Boolean | Char | SByte |
Byte | Int16 | UInt16 | Int32 | UInt32 | Int64 | UInt64 |
Single | Double | Decimal | DateTime | String"
/>
<asp:QueryStringParameter
ConvertEmptyStringToNull = "True | False"
DefaultValue = "string"
Direction = "Input | Output | InputOutput | ReturnValue"
Name = "string"
QueryStringField = "string"
Size = integer
Type = "Empty | Object | DBNull | Boolean | Char | SByte |
Byte | Int16 | UInt16 | Int32 | UInt32 | Int64 | UInt64 |
Single | Double | Decimal | DateTime | String"
/>
<asp:SessionParameter
ConvertEmptyStringToNull = "True | False"
DefaultValue = "string"
Direction = "Input | Output | InputOutput | ReturnValue"
Name = "string"
SessionField = "string"
Size = integer
Type = "Empty | Object | DBNull | Boolean | Char | SByte |
Byte | Int16 | UInt16 | Int32 | UInt32 | Int64 | UInt64 |
Single | Double | Decimal | DateTime | String"
/>
</UpdateParameters>
</asp:AccessDataSource>
For information on the individual members of this class, see AccessDataSource in the class library.
The AccessDataSource class is a data source control used for working with Microsoft Access databases in ASP.NET Web Forms.
At a minimum, an AccessDataSource control needs at least the following properties to be set in order to function:
- the DataFile property, which sets the location of the Microsoft Access .mdb file to work with, and
- the SelectCommand property, which specifies the SQL query to execute on the data file.
For security, Access databases should be located in the App_Data
directory of the Web application, as this location is internally configured to reject direct HTTP requests to the data files from client browsers.
The data files can be accessed only by applications running on the same domain, using an absolute or a relative path, such as
datafile = "~/App_Data/Northwind.mdb"
The AccessDataSource class does not support connecting to Access databases that are protected by a user name or password, because the ConnectionString property of the control is set internally and can not be modified.
In these cases, the SqlDataSource control should be used, as this control provides for specifying parameters in the connection string.
Data controls are bound to an AccessDataSource using the DataSourceID property of the data-bound control. For more information on binding a data-bound control to data source controls, see Binding to Data Using a Data Source Control.
For more information on using the AccessDataSource control, see AccessDataSource Web Server Control.
The following example demonstrates a typical display scenario using AcessDataSource controls with a DropDownList and a GridView control.
Basically, this is how the controls work and interact:
- An AccessDataSource control is bound to the DropDownList control that provides a list of product categories from which the user makes a selection.
<asp:accessdatasource id="ProductType" runat="server"
datafile = "~/app_data/gear.mdb"
selectcommand = "SELECT distinct Type FROM Products"
datasourcemode = "DataReader" />
...
Select Category: <asp:dropdownlist id="filterType" runat="server"
datasourceid="ProductType" datatextfield = "Type"
autopostback />
- Another AccessDataSource control is bound to the GridView control, whose SelectCommand property is set to an appropriate SQL query that is filtered by the given FilterExpression, which is based on the user selection.
<asp:accessdatasource id="Products" runat="server"
datafile = "~/app_data/gear.mdb"
selectcommand = "SELECT Type, ProductId, Brand, Model, Description, Price FROM Products"
filterexpression = "Type='{0}'">
<filterparameters>
<asp:controlparameter controlid="filterType"
propertyname = "SelectedValue" />
</filterparameters>
</asp:accessdatasource>
- Each time the user makes a selection, the filtered data from the specified datafile is displayed in the GridView control.
<asp:gridview id="ProductsGrid" runat="server"
datasourceid="Products"
... />
Show me
AccessDataSource Class AccessDataSource Web Server Control