Click here to Skip to main content
14,387,712 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hi,
I want to create a access database and connect my asp.net project to that how can I do this?
Posted
Comments
Al Moje 12-Aug-11 3:50am
   
Use OleDb for your connection
Rate this:
Please Sign up or sign in to vote.

Solution 2

Connection strings for Access 2007[^]

here is the connection string.. check this one.

thanks..
   
Rate this:
Please Sign up or sign in to vote.

Solution 3

The code below will be in your web.config

<connectionStrings>
        <add name="ConnectionStringName" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|DatabaseName.mdb;Persist Security Info=True" providerName="System.Data.OleDb"/>
 </connectionStrings>


Now below this is how you will use your ConnectionString name in your class or code behind a page

//Method for A Database Connection
   public string dbConnection()
   {

       string connString = ConfigurationManager.ConnectionStrings["ConnectionStringName"].ConnectionString;

       try
       {
           // set up and open connection
       dbConn = new OleDbConnection(connString);
        dbConn.Open();

       }

       catch (OleDbException exp)
       {
          MessageBox.Show(exp.Message);
       }
       return connString;

   }


maybe u will need the following namespace

using System.Configuration;


Hope it helps...
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100