Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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

Connection strings for Access 2007[^]

here is the connection string.. check this one.

thanks..
 
Share this answer
 
The code below will be in your web.config

XML
<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

C#
//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

C#
using System.Configuration;


Hope it helps...
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900