如何从访问vb.net插入和检索日期和时间 [英] How to insert and retreive date and time from access to vb.net

查看:145
本文介绍了如何从访问vb.net插入和检索日期和时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我使用ado控件连接访问权限2003.现在我无法插入日期和时间。它给了我错误。

所以任何人都可以给我代码如何从vb.net插入日期访问数据库。



代码我用的是



在记录集中添加日期

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

recordset.field("DATE").value= DateTimePicker1.value





从记录集中检索日期



to retrieve date from recordset

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

推荐答案

参考文献:

References:
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.


这篇关于如何从访问vb.net插入和检索日期和时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆