im tring to insert new data to an Access table. the table has 4 parameters. the first one is an autonumber. this is my code:
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
im getting this error:
ErrorCode=-2147217900