SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseSQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old February 10th, 2004, 07:36 AM
fake_thug fake_thug is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 9 fake_thug User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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!

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseSQL Development > ASP/SQL help req'd!


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT