MSAccess and SqlDataSource

I'm writing this article about working with MSAccess and SqlDataSource for my old good friend, Yoram Varon (YVIT).

First we have to add a ConnectionString in our web.config file: Open web.config and write inside <connectionString> tag:

<add name="MyConStr" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\Database1.mdb;Persist Security Info=True"

      providerName="System.Data.OleDb" />

The property "name" is the name of our ConnectionString (in this case, 'MyConStr').
Pay attention that you may use |DataDirectory| in place of the full path to your App_Data directory inside your virtual directory.

Next, inside our ASP.NET document, we add a SqlDataSource control, with this properties:

<asp:SqlDataSource ID="SqlDataSource1"  runat="server"

    ConnectionString="<%$ ConnectionStrings:MyConStr %>"

    ProviderName="<%$ ConnectionStrings:MyConStr.ProviderName %> DeleteCommand="DELETE Statement" InsertCommand="INSERT Statement" SelectCommand="SELECT Statement" UpdateCommand="UPDATE Statement"


Now, we may add a GridView control or any other Data Control, and bind it to our SqlDataSource.



Comments have been disabled for this content.