Click here to Skip to main content
15,896,269 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How do I connect my ASP.NET Web Page with the Microsoft Access Database? Someone please help me out.
Posted

Short answer: use ADO.NET:
http://en.wikipedia.org/wiki/ADO.NET[^],
http://msdn.microsoft.com/en-us/library/aa286484.aspx[^].

For a beginner, I find this CodeProject article most useful:
Using ADO.NET for beginners[^].

Good luck,
—SA
 
Share this answer
 
hi,

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


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

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

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

    }

    catch (OleDbException exp)
    {

    }
    return connString;

}


maybe u will need the following namespace


using System.Configuration;

Hope it helps...

Best Luck
Happy Coding :)
 
Share this answer
 
This will give you a complete tutorial on all basic data access operations

A Beginner's Tutorial for Understanding ADO.NET[^]
 
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