Odbc Paradox 驱动程序 WHERE 子句 日期
我正在使用带有 Paradox 的 Odbc 驱动程序。 我有一张表,里面有日期。 我正在尝试按该列中的日期进行查询。 我似乎无法让 where 子句发挥作用。 我可以通过整数搜索记录,但我不知道如何使用日期时间。
OdbcCommand comm= new OdbcCommand("SELECT * FROM [Journal] WHERE" +
"[Date] = 04/02/2009 ",
new OdbcConnection(@"Driver={Microsoft Paradox Driver (*.db )};DriverID=538;Fil=Paradox 5.X;DefaultDir=d:\\ics\\tables\\HISTORY;Dbq=d:\\ics\\tables\\HISTORY;CollatingSequence=ASCII"));
OdbcDataAdapter adapt = new OdbcDataAdapter(comm);
DataTable table = new DataTable();
adapt.Fill(table );
I am using an Odbc driver with Paradox. I have a table with a date in it. I am trying to query by the date in that column. I can't seem to get the where clause to work. I can get the record searching by ints, but I don't know how to use the date time.
OdbcCommand comm= new OdbcCommand("SELECT * FROM [Journal] WHERE" +
"[Date] = 04/02/2009 ",
new OdbcConnection(@"Driver={Microsoft Paradox Driver (*.db )};DriverID=538;Fil=Paradox 5.X;DefaultDir=d:\\ics\\tables\\HISTORY;Dbq=d:\\ics\\tables\\HISTORY;CollatingSequence=ASCII"));
OdbcDataAdapter adapt = new OdbcDataAdapter(comm);
DataTable table = new DataTable();
adapt.Fill(table );
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,我想通了。
在 odbc 中,您必须使用 {} 来定义对象,d 定义日期的格式。
您可以使用以下内容。
{d '值'} yyyy-mm-dd
{t '值'} hh:mm:ss
{ts '值'} yyyy-mm-dd hh:mm:ss
Ok I figured it out.
In odbc you have to use the {} to define an object, and the d defines the format of the date.
You can use the following.
{d 'value'} yyyy-mm-dd
{t 'value'} hh:mm:ss
{ts 'value'} yyyy-mm-dd hh:mm:ss
在 Paradox 中查找可将字符串转换为日期的日期/时间函数。 像在 SQL 中一样使用字符串作为日期是非常棘手的。 必须有一些像 TO_DATE 或类似的函数可以为您正确格式化它。
Look for Date/Time functions in Paradox that will convert a string to a date. It is very tricky to use a String as a date like in your SQL. There must be some functions like TO_DATE or similar that will properly format it for you.