Hey all,

Hope ye are all are enjoying christmas,


I was just wondering if someone could help me out I am having a small problem with insterting a Date into Access 2007. I am Using the Now() Function in VB.NET and have change the format to General date In Access 2007 so both formats seem to match.
However is does not work the try statement says there is a problem with My insert statement.


So I remove the Date Value and there are no problems so it must be somthing when i try to insert the Date into the field .
Here are the insert statements I have used. and none work

OleCommand_Insert = New OleDbCommand("INSERT INTO tblMachineHistory(Make,Model,HP,Problem,Drop,Extra_Info,Customer_ID,Rating) Values ('" & Make & "','" & Model & "','" & HP & "','" & Now & "','" & MacProblem & "','" & Extra_Info & "'," & CustomerID & "," & Min & ")", Connection_Insert)
 
OleCommand_Insert = New OleDbCommand("INSERT INTO tblMachineHistory(Make,Model,HP,Problem,Drop,Extra_Info,Customer_ID,Rating) Values ('" & Make & "','" & Model & "','" & HP & "'," & Now & ",'" & MacProblem & "','" & Extra_Info & "'," & CustomerID & "," & Min & ")", Connection_Insert)
           
OleCommand_Insert = New OleDbCommand("INSERT INTO tblMachineHistory(Make,Model,HP,Problem,Drop,Extra_Info,Customer_ID,Rating) Values ('" & Make & "','" & Model & "','" & HP & "'," & DateTime.Now & ",'" & MacProblem & "','" & Extra_Info & "'," & CustomerID & "," & Min & ")", Connection_Insert)

I would be very greatful if someone could give me hand with this thanks ,

Edited 6 Years Ago by JAM1011: Layout

Hi,

Use the "[]" in the date field "drop".

Here is the insert statement;

OleCommand_Insert = New OleDbCommand("INSERT INTO tblMachineHistory(Make,Model,HP,Problem,[B][Drop][/B],Extra_Info,Customer_ID,Rating) Values ('" & Make & "','" & Model & "','" & HP & "','" & Now.ToString() & "','" & MacProblem & "','" & Extra_Info & "'," & CustomerID & "," & Min & ")", Connection_Insert)

Since the "Drop" is a keyword it is throwing error.

Thank you.

This question has already been answered. Start a new discussion instead.