C# .NET - Another Problem using MSAccess DataBase with C#

Asked By Amin Yazdani on 03-Nov-05 01:52 PM
hi,
i use this code to connect to MSAccess via C# :
OleDbConnection conn = new OleDbConnection();
OleDbDataAdapter da = new OleDbDataAdapter();
DataSet ds=new DataSet();
conn.ConnectionString "Provider=Microsoft.Jet.OLEDB.4.0; User ID=Admin; Data source=d:\Ordu.mdb";
conn.Open();
da.SelectCommand = new OleDbCommand("Select * from Ordu",conn);
da.Fill(ds);
if (conn.State!=ConnectionState.Closed) 
{ 
conn.Close();
}

but there is some problems.
i want to insert some rows to my table, i don't know how to insert them!

please help me about that!
tnx,
Amin

To Insert any rows, - Asked By Aarthi Saravanakumar on 03-Nov-05 01:55 PM

Set the InsertCommand of the DataAdapter to be the stored procedure that should do the insert. Set the parameters, source columns etc.
Now add the new row to the DataSet.
When you are ready to insert into Access,
Call DaatAdapter.Update(ds);

Example please - Asked By Amin Yazdani on 03-Nov-05 03:53 PM

could u please make an exmaple 4 me?

Link - Asked By Aarthi Saravanakumar on 03-Nov-05 03:56 PM

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdataoledboledbdataadapterclassinsertcommandtopic.asp