try
{
string mycon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=test.mdb";
string temp = "insert into user (username, password, email) values ('a','b','c') ";
this.oleDbConnectionTest.ConnectionString = this.mycon;
this.oleDbConnectionTest.Open();
MessageBox.Show(temp);
oleDbCommandTest.CommandType = CommandType.Text;
oleDbCommandTest.CommandText = temp;
oleDbCommandTest.Connection = oleDbConnectionTest;
//oleDbDataAdapterTest.InsertCommand = oleDbCommandTest; //oleDbDataAdapterTest.Update(testDataSet.Tables["user"]);
oleDbCommandTest.ExecuteNonQuery();
//oleDbDataAdapterTest.InsertCommand.ExecuteNonQuery();
}
catch(Exception ee) {
MessageBox.Show(ee.ToString());
}
{
string mycon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=test.mdb";
string temp = "insert into user (username, password, email) values ('a','b','c') ";
this.oleDbConnectionTest.ConnectionString = this.mycon;
this.oleDbConnectionTest.Open();
MessageBox.Show(temp);
oleDbCommandTest.CommandType = CommandType.Text;
oleDbCommandTest.CommandText = temp;
oleDbCommandTest.Connection = oleDbConnectionTest;
//oleDbDataAdapterTest.InsertCommand = oleDbCommandTest; //oleDbDataAdapterTest.Update(testDataSet.Tables["user"]);
oleDbCommandTest.ExecuteNonQuery();
//oleDbDataAdapterTest.InsertCommand.ExecuteNonQuery();
}
catch(Exception ee) {
MessageBox.Show(ee.ToString());
}
谢谢各位。好了现在。就是因为user password是关键字。
-----------------? 你的是在ACCESS中的嗎?如果是在MS SQL中,這些是要處理下的。但是我剛在ACCESS中測試了下,你這段代碼是OK的。