Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to specify date range for query (VFP9 OleDB)
Message
From
27/02/2006 16:58:06
 
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
VB.NET 1.1
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01099668
Message ID:
01099686
Views:
14
John,

I think you need to take the date strings, convert them to dates, and then use the dates variables. So, first get the date variables:
   dim dRdate1   as DateTime = DateTime.Parse(Request.Item("d1"))
   dim dRdate2   as DateTime = DateTime.Parse(Request.Item("d2"))
Then use the date variables in your string:
dim MySql as string=String.Format("select sdate1,sdate2,Title from Sess " + _
"where id_code={0} and between(sdate1,{1},{2}), Request.Item("ID"), dRdate1, dRdate2)
~~Bonnie




>I have a fairly complex query that works fine in ASP.NET, returning the results in a sortable datagrid. Now I just need to be able to filter by date, so I've got two text boxes to collect the start and end date, which I then stick on the end of the URL:
>
> callingURL.aspx/?ID=1302&d1=7/1/2005&d2=7/31/2005
>
>I'm then able to grab the two dates:
>
> dim dRdate1 as string = Request.Item("d1")
> dim dRdate2 as string = Request.Item("d2")
>
>But I keep getting operator/operand type mismatches when I go to the page. Here's a simplified version of the code:
>
>dim MySql as string=String.Format("select sdate1,sdate2,Title from Sess " + _
>"where id_code={0} and between(sdate1," & dRdate1 & "," & dRdate2 & "), Request.Item("ID"))
>
>
>In the BETWEEN() function I've tried putting the variables in quotes, CTOD(), even tried #dRdate1# (most of the examples I could find are for Access). Also tried defining the variables as date instead of string. Also tried not using BETWEEN():
>
>"where id_code={0} and sdate1 >= " & dRdate1 & " and sdate1 <=" & dRdate2, Request.Item("ID"))
>
>I'm probably making this a lot harder than it needs to be. Could someone point out how to get these dates to work? Any suggestions appreciated.
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform