即時通訊新這裏,我想更新,並從DataGridView中以及從數據庫中我有以下的更新代碼和刪除刪除的記錄..更新和刪除記錄
int num = 0;
foreach (DataGridViewRow row in this.dataGridView1.Rows)
{
if (Convert.ToBoolean(row.Cells[0].Value))
{
string ID = this.dataGridView1.Rows[row.Index].Cells["ID"].Value.ToString();
string CoCode = this.dataGridView1.Rows[row.Index].Cells["CoCode"].Value.ToString();
string CoName_mar = this.dataGridView1.Rows[row.Index].Cells["CoName_mar"].Value.ToString();
con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Documents and Settings\\mayur patil\\My Documents\\Dairy_db\\tblCompany_1.mdb";
con.Open();
OleDbCommand cmd = new OleDbCommand("UPDATE tblCompany_1 SET ([email protected],[email protected]_mar where [email protected])", con);
cmd.Parameters.AddWithValue("CoCode", CoCode);
cmd.Parameters.AddWithValue("CoName_mar", CoName_mar);
cmd.Parameters.AddWithValue("ID", ID);
cmd.ExecuteNonQuery();
con.Close();
num++;
}
}
if (num > 0)
{
MessageBox.Show("Record Updated !");
}
this.Hide();
listOfCompany v = new listOfCompany();
v.ShowDialog();
添加刪除記錄..
OleDbConnection con = new OleDbConnection();
con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Documents and Settings\\mayur patil\\My Documents\\Dairy_db\\tblCompany.mdb";
OleDbCommand cmd = new OleDbCommand ("DELETE FROM tblCompany WHERE (CoCode = i)");
con.Open();
cmd.ExecuteNonQuery();
con.Close();
的更新查詢即時得到的是「OleDbException被處理語法錯誤在UPDATE」的錯誤在
cmd.ExecuteNonQuery();
刪除查詢我得到錯誤「OleDbException被處理..找不到可安裝的ISAM。」 at
con.Open();
我該如何克服這個問題?
yuuup ............ – Barbie 2011-05-19 06:16:19
+ 1額外的空間;賓果! – 2011-05-19 06:16:30
對不起,它不工作...... :( – Barbie 2011-05-19 06:28:25