Lennie Kuah

Lennie Kuah

  • NA
  • 27
  • 0

VBNET2008 USING SQL STRING WITH DATE BETWEEN

Dec 25 2011 11:44 PM
 Hullo Good Guys,

Please help me, I do need your help. 

I am using VBNET2008 to develop Window Application using SQL STRING DATE BETWEEN Logic in the SQL STRING to retrieve data from SQL SERVER 2000 but it not working and generate error message.  I am very surprised

Error Message:

Invalid Column Name strFromDate

Invalid Column Name strToDate

Example of Coding

Dim strFromDate as string = me.TxtFromDate.Text.ToShortDateString

Dim strToDate as string = Me.TxtToDate.Text.ToShortDateString

Dim strsql As String = Nothing

 

Private sub FUseDateToSelectData()

strsql &= "Select OrderID, "

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

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

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

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

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

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

strsql &= "Order by OrderID, OrderDate"

 End Sub

 Please help me with sample correct Coding.

Thank you very much.

 CHEERS,

LENNIE KUAH


Answers (3)