日期:2014-05-18  浏览次数:20960 次

求教为何insert语句报错
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());
                        }

------解决方案--------------------
try:

string temp = "insert into [user] ([username], [password], [email]) values ( 'a ', 'b ', 'c ') ";
------解决方案--------------------
user是MS SQL的關鍵字,前後要用[]括起來。


------解决方案--------------------
insert into [user] (username, password, email) values ( 'a ', 'b ', 'c ')

------解决方案--------------------
user password 在ACCESS中是关键字,用[]括起来 或者改下别的名字就OK了
------解决方案--------------------
access就是要比SQL Server要烦些,楼上正解
------解决方案--------------------