Click here to Skip to main content
15,881,380 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello, I use ado control to connect access 2003. Now I am stuck in inserting date and Time. It gives me errors.
So Can anyone give me code how to insert date from vb.net to access database.

The code which I use is

to add date in the recordset
C#
recordset.field("DATE").value= DateTimePicker1.value


to retrieve date from recordset
C#
DateTimePicker.value=recordset.field("DATE").value

The errors which I get is

- Object reference not set to an instance of an object

- Conversion from type 'Date' to 'Boolean' is not valid
Posted
Updated 27-May-14 0:05am
v3
Comments
Richard MacCutchan 27-May-14 6:31am    
One of your references is not correctly set. Use your debugger to find out which one it is, and why it does not reference a valid object.
Member 10430192 27-May-14 6:36am    
Can you please say me what reference means and how do we set it???
Richard MacCutchan 27-May-14 6:45am    
Seriously? You are programming a .NET database application and you don't understand references? I suggest you get your reference manuals out and study them in detail.
Member 10430192 27-May-14 6:52am    
If you don't mind can you please explain me in short?

1 solution

References:
VB
recordset ' is a reference to a set of records, and must be initialised at the beginning of the program.
.field ' is a reference to a particular property of the recordset
("DATE") ' is a field qualifier which creates a reference to the "DATE" column in the recordset field array.
.value ' is a reference to the value in the DATE field.

If any of the above do not refer to a valid object then you will receive the errors you see. Understanding classes, objects and references is fundamental to being able to create working applications. If you really do not understand this then you should go back to your study guides or reference manuals until you do.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900