|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
ASP/SQL help req'd!
newbie here
ive been trying 2 do an asp/sql scripting but im having one problem. ive created asp that comes up with an sql string based on the user's selections from a drop-down box.basically it extract multiple values from a querystring and uses those values to create an SQL statement with multiple selection criteria. heres the code for that: <%@LANGUAGE="VBSCRIPT"%> <HTML> <HEAD> <BODY> <% Dim IntLoop Dim strSQL() Dim strValues strValues = "Select * from cottages" If Request.QueryString("destination").Count = 0 Then Response.Write "You have not selected any destinations. Please press the back button on your browser to try again." ElseIf Request.QueryString("destination").Count = 1 Then ReDim strSQL(0) If Request.QueryString("destination") <> "All" Then strSql(0) = Request.QueryString("destination")(1) strValues = strValues & " where destination = " & strSQL(0) End If Else ReDim strSQL (Request.QueryString("destination").Count -1 ) strValues = strValues & " where" For IntLoop = 0 To (Request.QueryString("destination").Count - 1) strSQL(IntLoop) = Request.QueryString("destination")(IntLoop + 1) strValues = strValues & " destination = " & strSQL(Intloop) If IntLoop <> (Request.QueryString("destination").Count - 1) Then strValues = strValues & " and " End If Next End If %> the second half of the code involves me using the sql string i.e. strValue, and checking it against an Oracle database. what i need to know is how i can use the generated strValue sql query. ive tried inserting the strValue in the strSQL field (but i keep getting error msgs) : <% Dim objConn, objRs strSQL = strValues Set objConn = Server.CreateObject("ADODB.Connection") objConn.Open "dsn=Oracle;uid=******;pwd=******;" Set objRs = objConn.execute(strSQL) %> <%If (objRs.BOF) then%> <P>Sorry, no cottages are available <%Else%> <P>Cottage Details ...<BR> <TABLE> <TR> <TD>Property Number</TD> <TD>Location</TD> <TD>Description</TD> </TR> <%Do While Not (objRs.EOF)%> <TR> <TD><%=objRs("prop_no")%></TD> <TD><%=objRs("location")%></TD> <TD><%=objRs("long_desc")%></TD> </TR> <% objRs.MoveNext Loop %> </TABLE> <% End If objRs.Close Set objRs=Nothing objConn.Close Set objConn=Nothing %> </BODY> </HTML> [/COLOR] all this is on one page like ive set out here. is there any other way of inserting the strValue into the strSQL code? thanks in advance if u can help. Goodbye. p.s. This is part of an assignment so it has to be kept simple! |
![]() |
| Viewing: ASP Free Forums > Database > SQL Development > ASP/SQL help req'd! |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|