J
jb
i try to delete a record using this code;
string ConStr = "Provider=Microsoft.Jet.OleDB.4.0; Data Source =" +
Application.StartupPath + "\\db1.mdb";
using (OleDbConnection Conn = new OleDbConnection(ConStr))
{
Conn.Open();
OleDbCommand Cmd = new OleDbCommand("Select * from table1 WHERE
PatientNo='" + "11-11001" + "'", Conn);
OleDbDataAdapter dAdapter = new OleDbDataAdapter(Cmd);
DataSet dDataSet = new DataSet();
dAdapter.Fill(dDataSet, "table1");
dDataSet.Tables["table1"].Rows[0].Delete();
dAdapter.Update(dDataSet, "table1");
dDataSet.AcceptChanges();
Conn.Close();
}
but the message is: Update requires a valid DeleteCommand when passed
DataRow collection with delete rows.
string ConStr = "Provider=Microsoft.Jet.OleDB.4.0; Data Source =" +
Application.StartupPath + "\\db1.mdb";
using (OleDbConnection Conn = new OleDbConnection(ConStr))
{
Conn.Open();
OleDbCommand Cmd = new OleDbCommand("Select * from table1 WHERE
PatientNo='" + "11-11001" + "'", Conn);
OleDbDataAdapter dAdapter = new OleDbDataAdapter(Cmd);
DataSet dDataSet = new DataSet();
dAdapter.Fill(dDataSet, "table1");
dDataSet.Tables["table1"].Rows[0].Delete();
dAdapter.Update(dDataSet, "table1");
dDataSet.AcceptChanges();
Conn.Close();
}
but the message is: Update requires a valid DeleteCommand when passed
DataRow collection with delete rows.