Hi
i have three fields
emp name
empid
emp dept
now i want to connect to acess db and want to populate the db with new records
Printable View
Hi
i have three fields
emp name
empid
emp dept
now i want to connect to acess db and want to populate the db with new records
So whats the problem then ?
It is similar to any other DBMS like SQL.
Use ODBCConnection and OdbcReader .In Connection String= ";dbq="Pathname of file;dsn=access files ";
see the sample below,
string dbConnString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Temp\test.mdb";
OleDbConnection dbConn = new OleDbConnection(dbConnString);
OleDbCommand dbCommand = new OleDbCommand();
dbCommand.Connection = dbConn;
dbConn.Open();
dbCommand.CommandType = CommandType.Text;
dbCommand.CommandText = "Select * from Employee";
OleDbDataReader dr = dbCommand.ExecuteReader();
while (dr.Read() == true)
{
Console.WriteLine(dr["uid"].ToString() + ":"+ dr["uname"].ToString() + ":" + dr["udept"].ToString());
}
dbConn.Close();