How to insert date and time into access (1 Viewer)

Tabrez

New member
Local time
Today, 01:38
Joined
May 27, 2014
Messages
4
I am using vb 2008, and i have successfully connected to access 2003 database using ado data control.
But I am unable to insert date and time and also retrieve it from data base.
The code which I use is

TO INSERT
recordset.fields("EntryDate").value= DateTimePicker.value

TO RETRIEVE
DateTimePicker.value=recordset.fields("EntryDate").value


It gives me errors.
Any suggestions will be appreciated
Thank you in advance
 

sumox

Registered User.
Local time
Today, 14:08
Joined
Oct 1, 2013
Messages
89
i know following shud work
Dim Kero As String
Kero= Date
... now insert you code bla bla for table update
this will set Kero as Today's Date
 

Tabrez

New member
Local time
Today, 01:38
Joined
May 27, 2014
Messages
4
I tried using string operator as u suggested, but its giving two run time errors

1)Conversion from type DBnull to type DATE is not valid
2)Object reference is not set to the instance of an object
 

sumox

Registered User.
Local time
Today, 14:08
Joined
Oct 1, 2013
Messages
89
pls. attach screen print of :
1. References library
2. Debug mode yellow line

in your next message
as if i am unable to assist you
any of AWF Members and Exp. will assist you.

thanks

K. sumox
 

sumox

Registered User.
Local time
Today, 14:08
Joined
Oct 1, 2013
Messages
89
Mines worked successfully
dialog box appeared with same.
 

Tabrez

New member
Local time
Today, 01:38
Joined
May 27, 2014
Messages
4
Thank you for your response
Were you able to insert date into access.. if yes can you please give me the code what you used.
 

vedika

Registered User.
Local time
Today, 14:08
Joined
Jan 24, 2019
Messages
11
You may try this code to insert data and time in MS Access using VB.Net

Dim purchasedatetime As Date = System.DateTime.Now
Str = "Insert into Customer_Order (Order_Date) values (@Order_Date)"
cmd = New OleDbCommand(Str, cn)
'open the connection
With cmd
.parameters.addwithvalue("@order_Date", purchasedatetime)
.ExecuteNonQuery()
End With
 

Users who are viewing this thread

Top Bottom