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"
Thank you very much.
Sushta GuthnarPosted Dec 29, 2011, 3:24 PM
Thanls,
Shusta
Sushta GuthnarPosted Dec 29, 2011, 2:50 PM
strsql &= "And (OrderDate between strFromDate and strToDate)" sjhould be happily saying:
strsql &= "And (OrderDate between '" + strFromDate + "' and '" + strToDate + "')"
you have literal variations of viarable refereceines.
Thans, happy afternoons,
Shucha
Satyapriya NayakPosted Dec 26, 2011, 4:40 AM
Change the below lines
Dim strFromDate as string = me.TxtFromDate.Text.ToShortDateString
Dim strToDate as string = Me.TxtToDate.Text.ToShortDateString
Dim strFromDate as string = me.TxtFromDate.Text.ToString
Dim strToDate as string = Me.TxtToDate.Text.ToString
Thanks