update with datagridview
-
Hi, My code like this public string str = "Provider=MSDAORA.1;user id=scott;password=tiger"; OleDbDataAdapter da ; DataSet ds = new DataSet(); OleDbConnection con = new OleDbConnection(str); da= new OleDbDataAdapter("select * from dept", con); da.Fill(ds, "dept"); dataGridView1.DataSource = ds.Tables["dept"]; I want data entered in the datagridview is updated when i click update button. In the button click event i write da.update(ds,"dept"),but it is giving the following exception: "Update requires a valid UpdateCommand when passed DataRow collection with modified rows." In INSERT button click i write like this: DataTable dt=new DataTable(); dt = (DataTable)dataGridView1.DataSource; DataRow dr = dt.NewRow(); dt.Rows.Add(); dataGridView1.DataSource = dt; Please help me. Thanks in advance
-
Hi, My code like this public string str = "Provider=MSDAORA.1;user id=scott;password=tiger"; OleDbDataAdapter da ; DataSet ds = new DataSet(); OleDbConnection con = new OleDbConnection(str); da= new OleDbDataAdapter("select * from dept", con); da.Fill(ds, "dept"); dataGridView1.DataSource = ds.Tables["dept"]; I want data entered in the datagridview is updated when i click update button. In the button click event i write da.update(ds,"dept"),but it is giving the following exception: "Update requires a valid UpdateCommand when passed DataRow collection with modified rows." In INSERT button click i write like this: DataTable dt=new DataTable(); dt = (DataTable)dataGridView1.DataSource; DataRow dr = dt.NewRow(); dt.Rows.Add(); dataGridView1.DataSource = dt; Please help me. Thanks in advance
-
if you want update your data in datagridview in data base you must first define sqlcommandbuilder before your update command: SqlCommandBuilder sc=new SqlCommandBuilder(DataAdaptorname);
I tried in this way also decimal dn=Convert.ToDecimal(textBox2.Text); string d=textBox3.Text; string l=textBox4.Text; string i="insert into dept values(dn,d,l)"; da.InsertCommand=new OleDbCommand(i,con); da.Update(ds, "dept"); It is not giving any error,But updations are not taking place against oracle database. Please help me.
-
I tried in this way also decimal dn=Convert.ToDecimal(textBox2.Text); string d=textBox3.Text; string l=textBox4.Text; string i="insert into dept values(dn,d,l)"; da.InsertCommand=new OleDbCommand(i,con); da.Update(ds, "dept"); It is not giving any error,But updations are not taking place against oracle database. Please help me.
-
I tried in this way also decimal dn=Convert.ToDecimal(textBox2.Text); string d=textBox3.Text; string l=textBox4.Text; string i="insert into dept values(dn,d,l)"; da.InsertCommand=new OleDbCommand(i,con); da.Update(ds, "dept"); It is not giving any error,But updations are not taking place against oracle database. Please help me.
Hi, in Oracle server, after insert/update execute COMMIT statement for permenent changes in the database. regards, uroojknan -- modified at 2:40 Saturday 27th May, 2006