VB.NET中的日期与MSAccess和SELECT [英] Date in VB.NET vs. MSAccess and SELECT

查看:61
本文介绍了VB.NET中的日期与MSAccess和SELECT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个简单的窗体上有一个日历,当我选择一个日期时,它会将日期放入一个格式为YYYY-MM-DD的文本框中


当我选择一个如果所选日期有任何约会,我会在MSAccess数据库中查找日期。

在文件中(数据库查询所在的位置)calendar.xsd我可以使用下面的查询我的所有appontments都列在我的数据网格中。

< CommandText> SELECT * FROM tbNotification< / CommandText>


但如果我想使用所选的我在文本框中的日期,我得到一个错误,说有一些值或参数丢失 (瑞典语的简单翻译,不知道确切的英文翻译)。我尝试使用的查询如下:

< CommandText> SELECT * FROM tbNotification WHERE([Date] =''#''+ txtSelDate +''#'')< / CommandText> ;


我试过了:

- 大约日期的##查询字符串中有很多语法

- put日期为字符串,日期等等

- 将日期作为变量(selDate = txtSelDate.text)


我现在已尽力而为考虑到。你们有没有人能解决我的问题?


我非常感谢任何帮助!


复活节快乐! :)

I have a calendar on a simple windows form and when I choose a date it will put the date into a textbox with the format YYYY-MM-DD

When I choose a date i look up in a MSAccess database if there is any appointments for the selected date.

In the file (where the database query is in) calendar.xsd i can use the query below and all my appontments is listed in my datagrid.
<CommandText>SELECT * FROM tbNotification</CommandText>

But If I want to use the selected date that I have in my textbox, i get an error saying that "There is some values or parameters missing" (a simple translation from Swedish, don′t know the exact English translation). The Query I try to use is the one below:
<CommandText>SELECT * FROM tbNotification WHERE ([Date] = ''#''+txtSelDate+''#'')</CommandText>

I have tried:
- ALOT of syntaxes in the query string for the ## around the date
- putting the date as String, as Date etc etc
- putting the date as a variable (selDate = txtSelDate.text)

I have now tried everything I can think of. Does anyone of you guys a solution for my problem?

I''m extremely thankful for any help!

Have a nice easter! :)

推荐答案

Hello bixfeldt,


在Access数据库中,如何存储Date字段?文字或日期/时间?


CroCrew~
Hello bixfeldt,

In your Access database how is the field “Date” being stored? Text or Date/time?

CroCrew~


我已经尝试了日期/时间和文本,但目前我将其存储为文本,不是日期/时间格式。
I have tried both Date/Time and Text but for the moment I store it as Text, not in Date/Time format.


正确的方法是将其存储为日期/时间。还有吗?约会?是保留字,不应用作您的字段名称。聪明的你的字段名称。喜欢?NotificationDate?。


有了这个,请告诉我们你如何存储它以及该字段的名称,我们将尽力为您提供答案。另外,如果您要将数据存储为?文本?给我们一些你存储的例子。


再次,我个人不会将日期存储为文本。


CroCrew~
Well the correct way is to store it as a Date/Time. Also ?Date? is a reserved word and should not be used as your field name. Be clever with your field names. Like ?NotificationDate?.

With that said let us know how you?re going to store it and the name of the field and we will try to provide you with your answer. Also, if you are going to store the data as a ?text? give us some examples of what you have stored.

Again, I personally would not store dates as text.

CroCrew~


这篇关于VB.NET中的日期与MSAccess和SELECT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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