我正在與C#一起工作。以c#形式插入記錄
我想在表格中插入記錄。我正在使用MS Access數據庫。我有以下代碼:
private void button1_Click(object sender, EventArgs e)
{
con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;
Data Source=C:\\Documents and Settings\\mayur patil\\
My Documents\\Dairy_db\\tblCompany.mdb";
con.Open();
OleDbCommand cmd = new OleDbCommand(
"INSERT INTO tblCompany (CoCode,CoName_mar)
VALUES("+textBox1.Text+","+textBox4.Text+")", con);
cmd.ExecuteNonQuery();
con.Close();
this.Hide();
Form1 f = new Form1();
f.ShowDialog();
}
我沒有得到答案..
你有什麼異常? CoCode,CoName_mar的數據類型是什麼? – 2011-05-17 07:00:16
yuup ...它在「INSERT INTO」命令中給出錯誤... – Rockstar 2011-05-17 07:01:12
您能否把整個異常消息? – 2011-05-17 07:02:12