المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Update method problem



C# Programming
01-21-2010, 05:50 AM
Hello,

I want to add a row to my database but it was being added and I get Syntax error in INSERT command

My code is as follows

System.Data.OleDb.OleDbConnection con;
DataSet ds1;
System.Data.OleDb.OleDbDataAdapter da;


con = new System.Data.OleDb.OleDbConnection();
ds1 = new DataSet();
da = new System.Data.OleDb.OleDbDataAdapter();
con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Dataource=C:\\stu.mdb";
string sql = "SELECT * from Marks";
da = new System.Data.OleDb.OleDbDataAdapter(sql,con);
con.Open();
da.Fill(ds1, "Marks");


DataRow drow = ds1.Tables[0].NewRow();
drow[0] = 124;
drow[1] = 13;
drow[2] = 14;
drow[3] = 15;
drow[4] = 30;
ds1.Tables[0].Rows.Add(drow);

System.Data.OleDb.OleDbCommandBuilder command = new System.Data.OleDb.OleDbCommandBuilder(da);
da.Update(ds1, "Marks");con.Close();



There is error in Update command and the row is not added

thankyou
Pritha