.NET中的SQL查询与DATETIME问题 [英] SQL query in .NET with DATETIME issues

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

问题描述

我在vb.net工作。我正在尝试为将过滤数据的表适配器创建查询。查询是

I''m working in vb.net. I''m trying to create a query for a table adapter that will filter data. The query is

展开 | 选择 | Wrap | 行号

推荐答案

在您当前的情况下,如果您的datetime变量是字符串格式,请将其包围''会将其视为日期时间

In your current situation, if your datetime variable is in the string format, surrounding it with '' will implictly cast it as a datetime

展开 | 选择 | Wrap | 行号


您好,


要删除错误,您必须将两个日期转换为相同的格式。您可以这样做:

在您的vb .net代码格式中,LoginDate值如下:


例如
Hi,

To remove the error you have to convert both the dates into same format . You can do this way :
In your vb .net code format LoginDate value as following :

e.g.
展开 | 选择 | Wrap | 行号


感谢您的回复。


不幸的是,我一直在同一件事情。我试图转换为varchar,但表仍然是空白的。我试过这种格式,但它并不是公认的功能。我还尝试将@LoginDate放入''''',但它不再将其识别为参数。我也尝试将参数类型更改为DateTime,但我仍然收到一个空白表。



我试过<和>到位,如果=只是为了看看它会发生什么。

Thank you for your replies.

Unfortunately, I keep getting the same thing. I tried to convert to varchar, but the table was still blank. I tried the format, but it wasn''t'' "a recognized function." I also tried to put the @LoginDate in '''' but it quit recognizing it as a parameter. I also tried changing the parameter type to DateTime, but I still received a blank table.



I tried < and >in place if the = just to see what it would happen.

展开 | 选择 < span class =codeDivider> | Wrap | 行号


这篇关于.NET中的SQL查询与DATETIME问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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