Sunday, 30 December 2012 13:55

accessing access database in csharp dot net application

Written by 
Rate this item
(0 votes)

access database file is easy to use than sql server
or MySql server databases.for accessing access db
System.Data.OleDb namespace used.following are
steps are needed to use access db in .net

1.first initialize connection -

OleDbConnection conn = new OleDbConnection(@"Provider=
Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|db.mdb;
Jet OLEDB:Database Password=csharp");

2.and then the following example shows rest -

using (DatabaseConnection)
OleDbCommand cmd = new OleDbCommand("SELECT * from dbtable",
OleDbDataReader reader = cmd.ExecuteReader();
if (reader.HasRows == true)
Label1.Text = reader.GetDateTime(0).ToShortDateString();
Label1.Text = "Unknown";

Read 3024 times
Super User

Email This email address is being protected from spambots. You need JavaScript enabled to view it.

Latest discussions

  • No posts to display.