插入错误,以便将新数据插入Access表。 该表有4个参数。第一个是自动编号。 这是我的代码:使用access + asp.net/C#
public void InsertToDB(int stationId, DateTime dateTime, double temperture)
{
connect.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Database1.accdb";
OleDbCommand cmd = new OleDbCommand();
cmd.Connection = connect;
cmd.CommandText = "Insert Into TempDate (StationID,DateTime,Temper)" + "Values(@ID,@dateTime,@temper)";
cmd.Parameters.Add("@ID", OleDbType.Integer).Value = stationId;
cmd.Parameters.Add("@dateTime", OleDbType.Date).Value = dateTime;
cmd.Parameters.Add("@temper", OleDbType.Double).Value = temperture;
connect.Open();
cmd.ExecuteNonQuery(); //At this line exception is generating
connect.Close();
}// insert to db
即时得到这个错误:
错误码= -2147217900
也许只是把该错误代码到谷歌搜索?已经给出了如此多的结果如何解决它,例如http://stackoverflow.com/questions/13898551/i-am-getting-an-error-when-i-try-to-update-records-in-my- access-database – walther 2014-09-06 14:51:00