Shane Fagan
Shane Fagan

Reputation: 101

Inserting a date into an access db in vb

Im a little stuck and I dont know what im doing wrong. I want to insert the current date into a MS Access database in VB. The part of the code im having trouble with is:

SQLString = "INSERT INTO Sales(DateSold) VALUES ("

SQLString += Date.Today & ")"

The type in the database is date and is dd/mm/year. Thanks in advance for the help.

Upvotes: 2

Views: 7933

Answers (3)

Tikeb
Tikeb

Reputation: 1068

You could use CultureInfo to set the formats of your datetimes?

Upvotes: 0

danseagrave
danseagrave

Reputation: 328

If you didn't what to use the SQL NOW() you could wrap the date in quotes:

SQLString = "INSERT INTO (Sales) VALUES ("

SQLString += "'" & Date.Today & "')"

Upvotes: 2

Jabezz
Jabezz

Reputation: 1312

why don't you let access handle the date:

"INSERT INTO Sales VALUES (NOW())"

Upvotes: 0

Related Questions