Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to update "Date" field into table ?

Status
Not open for further replies.

kianang

Technical User
Dec 2, 2002
23
SG
I tried to update "date" filed in my table form my Datetimepicker from a Windows form. The SQL is :

strSQL = "UPDATE Employee SET Dob = Datetimepicker1.value WHERE EmployeeID = 10001

However , the DOB field is alwasys updated as 01/01/1900

I tried get many get answer from some reference book ,but most of example are in updating String and Integer . I really need someone who knows the ways to update "date" field. Thank you .
 
Code:
strSQL = "UPDATE Employee SET Dob = Datetimepicker1.value WHERE EmployeeID = 10001

I'm sure you meant to type:
Code:
strSQL = "UPDATE Employee SET Dob = '" & Datetimepicker1.value & "' WHERE EmployeeID = 10001"

Because if you forget to escape the VB part of it, you will always get a low-value date (the 1/1/1900 you were getting).

A better way would be to use ADO parameters. Do a keyword search on that phrase and you should find some sample code that has been posted here before.

Chip H.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top