Get ready for BLACK FRIDAY shopping starting in

Forums

This topic is locked

Order by... when you use strings?

Posted 15 Apr 2002 19:44:40
1
has voted
15 Apr 2002 19:44:40 Garo Maka posted:
Im working on this event calender, and I need to ordered by startdate.

But im using strings in the recordset and cant get the order by to work. I have tryed in the recordset itself and then in the string, but wont work.

Here is the code, if you can help me figuring it out i will be very greatful.

<%
varWhereString = "WHERE Event_ID <> -1 ORDER BY Start_Date "
IF Request("txtFromDate" <>"" Then
AndFromDateString = " AND Start_Date >= #" & Request("txtFromDate" & "#"
Else
AndFromDateString = ""
End If

IF Request("txtToDate" <>"" Then
AndToDateString = " AND End_Date <= #" & Request("txtToDate" & "#"
Else
AndToDateString = ""
End If

IF Request("selAmt" <>"" Then
AndAmtString = " AND Amt LIKE '%" & Request("selAmt" & "%'"
Else
AndAmtString = ""
End If

varWhereString = varWhereString & AndFromDateString & AndToDateString & AndAmtString
%>
<%
set rsDate = Server.CreateObject("ADODB.Recordset"
rsDate.ActiveConnection = MM_connDezzPortal_STRING
rsDate.Source = "SELECT * FROM tblEvents " &varWhereString
rsDate.CursorType = 0
rsDate.CursorLocation = 2
rsDate.LockType = 3
rsDate.Open()
rsDate_numRows = 0
%>

Replies

Replied 15 Apr 2002 20:03:20
15 Apr 2002 20:03:20 Owen Eastwick replied:
Try it like this:

<%
varWhereString = "WHERE Event_ID <> -1"
IF Request("txtFromDate" <>"" Then
AndFromDateString = " AND Start_Date >= #" & Request("txtFromDate" & "#"
Else
AndFromDateString = ""
End If

IF Request("txtToDate" <>"" Then
AndToDateString = " AND End_Date <= #" & Request("txtToDate" & "#"
Else
AndToDateString = ""
End If

IF Request("selAmt" <>"" Then
AndAmtString = " AND Amt LIKE '%" & Request("selAmt" & "%'"
Else
AndAmtString = ""
End If

varWhereString = varWhereString & AndFromDateString & AndToDateString & AndAmtString & " ORDER BY Start_Date ASC"
%>
<%
set rsDate = Server.CreateObject("ADODB.Recordset"
rsDate.ActiveConnection = MM_connDezzPortal_STRING
rsDate.Source = "SELECT * FROM tblEvents " &varWhereString
rsDate.CursorType = 0
rsDate.CursorLocation = 2
rsDate.LockType = 3
rsDate.Open()
rsDate_numRows = 0
%>


Regards

Owen.

Multiple Parameter UD4 / Access 2000 Database Search Tutorial:
www.tdsf.co.uk/tdsfdemo
Replied 16 Apr 2002 01:52:16
16 Apr 2002 01:52:16 Garo Maka replied:
Thanks it works!

Reply to this topic