I tried execute INSERT query, but it throwing above error. I have given my code below
public string InsertMoveDetails(string desc, string currentLocation, string newLocation, string newBay, string requestedBy, string movedBy, string approvedBy, DateTime dateOfMove)
{
string desc, currentLocation, newLocation, movedBy, approvedBy, requestedBy,newBay;
DateTime dateOfMove;
desc = textBoxDescription.Text;
currentLocation = textBoxCurrentLocation.Text;
newLocation = comboBoxNewLocation.Text;
movedBy = comboBoxMovedBy.Text;
approvedBy = comboBoxApprovedBy.Text;
dateOfMove = dateTimePickerDateOfMove.Value;
newBay = textBoxNewBay.Text;
requestedBy = textBoxRequestedBy.Text;
con.Open();
OleDbCommand cmd1 = new OleDbCommand("INSERT INTO MoveDetails(Descrptn, CurrentLocation, NewLocation, NewBay, RequestedBy, MovedBy, ApprovedBy, DateOfMove) VALUES(@Descrptn, @CurrentLocation, @NewLocation, @NewBay, @RequestedBy, @MovedBy, @ApprovedBy, @DateOfMove)", con);
cmd1.Parameters.AddWithValue("@Descrptn", desc);
cmd1.Parameters.AddWithValue("@CurrentLocation", currentLocation);
cmd1.Parameters.AddWithValue("@NewLocation", newLocation);
cmd1.Parameters.AddWithValue("@NewBay", newBay);
cmd1.Parameters.AddWithValue("@RequestedBy", requestedBy);
cmd1.Parameters.AddWithValue("@MovedBy", movedBy);
cmd1.Parameters.AddWithValue("@ApprovedBy", approvedBy);
cmd1.Parameters.AddWithValue("@DateOfMove", dateOfMove);
cmd1.ExecuteNonQuery();
con.Close();
return "";
}
My database design is
Descrptn- Text
CurrentLocation- Text
NewLocation- Text
NewBay- Text
RequestedBy- Text
MovedBy- Text
ApprovedBy- Text
DateOfMove- Date/Time
Please help me with this error. I tried the other threads with same error, but i can't find the answer.