VBNEt2008 SQL STRING DATE BETWEEN [英] VBNEt2008 SQL STRING DATE BETWEEN

查看:78
本文介绍了VBNEt2008 SQL STRING DATE BETWEEN的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hullo Good Guy,


我正在使用VBNEt2008开发使用SQL SERVER 2000的窗口应用程序和带有DATE BETWEEN LOGIC的SQL STRING,它不能处理这些错误消息:


错误消息:


列名无效&ndquo; strFromDate


无效的列名称“ strToDate


以下是整体编码:


Dim strFromDate as string = Me.TxtDateFrom.text.to.shortDateString


Dim strToDate as string = Me.TxtDateTo.text.to.shortDateString


 


 


私人
Sub FLoadDataGridView()


    Dim strsql
作为 字符串 =
无/ span>


 
strsql& ="选择订单ID,"


 
strsql& =" convert(varchar(10),OrderDate,103)as [OrderDate],"


 
strsql& ="转换(数字(10,2),折扣)为[折扣],"


 
strsql& =" convert(numeric(10,2),ExtendedPrice)as [ExtendedPrice],"


 
strsql& =" convert(numeric(10,2),Freight)为[Freight]"


 
strsql& ="来自TblInvoices,其中CustomerID ='"& strcustID&"'"


 
strsql& =" And(在DiscFromDate和strToDate之间的OrderDate)"


 
strsql& =" Order by OrderID,OrderDate"


 


结束子


请帮助我。我非常需要你在SQL STRING中与DATE BETWEEN编码相同的帮助


非常感谢你帮助我。


干杯,


Lennie


 


非常感谢,祝你有个美好的一天。干杯,Lennie

解决方案

Hi Tee,


字符串连接存在问题,请按照下面的说明进行更正。它应该解决。


更改此行代码 来自:


strsql& =" And(在DiscFromDate和strToDate之间的OrderDate)"


to:



strsql& =" And(OrderDate介于 "&  strFromDate& ; " 和"&"  strToDate)"



获取约会BETWEEN的语法是如下例所示。



SELECT



*
FROM
日志
WHERE
时间戳
BETWEEN
'20011212'
AND


  -Mohammed Ghouse Ibne Barq Kadapavi

http://www.ProgrammersVision.blogspot.com

https://sites.google.com/site/BarqKadapavi

请将回答您问题的帖子标记为答案,并标记其他有用的帖子很有帮助。



" 20020105’


Hullo Good Guy,

I am using VBNEt2008 to develop Window Application using SQL SERVER 2000 and SQL STRING with DATE BETWEEN LOGIC and it's not working with these error messge:

Error Message :

Invalid column name “strFromDate

Invalid column name “strToDate

Here are the overall coding:

Dim strFromDate as string = Me.TxtDateFrom.text.to.shortDateString

Dim strToDate as string = Me.TxtDateTo.text.to.shortDateString

 

 

Private Sub FLoadDataGridView()

  Dim strsql As String = Nothing

  strsql &= "Select OrderID, "

  strsql &= "convert(varchar(10), OrderDate, 103) as [OrderDate], "

  strsql &= "Convert(numeric(10,2), Discount) as [Discount], "

  strsql &= "convert(numeric(10,2), ExtendedPrice) as [ExtendedPrice], "

  strsql &= "convert(numeric(10,2), Freight) as [Freight] "

  strsql &= "From TblInvoices where CustomerID = '" & strcustID & "'"

  strsql &= "And (OrderDate between strFromDate and strToDate) "

  strsql &= "Order by OrderID, OrderDate"

 

End sub

Please help me. I desperately need your help with the coding same of DATE BETWEEN in the SQL STRING

Thank you very much for helping me.

Cheers,

Lennie

 


Thank you very Much, Have a Good Day. Cheers, Lennie

解决方案

Hi Tee,

There is a problem in the string concatination, please correct this as shown below. It should solve.

Change this line of Code from:

strsql &= "And (OrderDate between strFromDate and strToDate) "

to:

strsql &= "And (OrderDate between " & strFromDate & " and " & " strToDate) "

The syntax for getting date BETWEEN is as shown below example.

SELECT

* FROM Log WHERE Timestamp BETWEEN '20011212' AND

 -Mohammed Ghouse Ibne Barq Kadapavi
http://www.ProgrammersVision.blogspot.com
https://sites.google.com/site/BarqKadapavi
Please mark the post answered your question as the answer, and mark other helpful posts as helpful.

'20020105'


这篇关于VBNEt2008 SQL STRING DATE BETWEEN的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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