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 ,

Recommended Answers

All 3 Replies

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.

Thanks Vey much.

I never would have got that.

Great :)

Please mark it as solved then.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.