Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP need some help talking to the db

Status
Not open for further replies.

Bri123456

Programmer
Jan 3, 2002
30
CA
Hi everyone, just wanted to ask a simple question on asp. I'm trying to display a list of values in a drop down box on my web page. this list is taken from a table in my database (let's call it dbtest) I have the PWS setup with the names that I have chosen. I can't get the list populated!!!. any samples will be greatly appreciated
 
Set objConn = Server.CreateObject( "ADODB.Connection" )
Set objCmd = Server.CreateObject( "ADODB.Command" )
Set objRS = Server.CreateObject( "ADODB.Recordset" )
objConn.Open Application("connectString")
Set objCmd.ActiveConnection = objConn
objCmd.CommandTimeout = 300



if request.servervariables("REQUEST_METHOD") = "POST" THEN
with objCmd
.commandText = "sp_rentEstSearch"
.CommandType =adCmdStoredProc
.parameters(1) = request("locCode")
.parameters(2) = request("agCode")
.parameters(3) = request("abCode")
.parameters(4) = request("leaseNum")
.parameters(5) = request("orderBy")
End With
set objRS = objCmd.Execute()
set objCmd = nothing

optionStr = &quot;<option value=''>Choose One&quot;
DO WHILE NOT objRS.EOF
optionStr = optionStr & &quot;<option value='&quot;& objRS(&quot;value&quot;) &&quot;'>&quot;&objRS(&quot;description&quot;)
objRS.movenext
LOOP
%>

<select name=&quot;mySelect&quot;><%=optionStr%></select> -- Just trying to help...
[wolf]<--- This is a wolf? We need a new icon.......
mikewolf@tst-us.com
 
Thank you very much for the quick response however I'm new at this asp language and I don't understand the code you put forth (maybe that's why can't get my drop down box working hahaha) If you have tim can you explain a little about the connection or from this point on
objConn.Open Application(&quot;connectString&quot;)
Set objCmd.ActiveConnection = objConn
objCmd.CommandTimeout = 300



if request.servervariables(&quot;REQUEST_METHOD&quot;) = &quot;POST&quot; THEN
with objCmd
.commandText = &quot;sp_rentEstSearch&quot;
.CommandType =adCmdStoredProc
.parameters(1) = request(&quot;locCode&quot;)
.parameters(2) = request(&quot;agCode&quot;)
.parameters(3) = request(&quot;abCode&quot;)
.parameters(4) = request(&quot;leaseNum&quot;)
.parameters(5) = request(&quot;orderBy&quot;)
End With
set objRS = objCmd.Execute()
set objCmd = nothing

optionStr = &quot;<option value=''>Choose One&quot;
DO WHILE NOT objRS.EOF
optionStr = optionStr & &quot;<option value='&quot;& objRS(&quot;value&quot;) &&quot;'>&quot;&objRS(&quot;description&quot;)
objRS.movenext
LOOP
%>

<select name=&quot;mySelect&quot;><%=optionStr%></select>

Thanks again for any assistance
 
Set objConn = Server.CreateObject( &quot;ADODB.Connection&quot; )
Set objCmd = Server.CreateObject( &quot;ADODB.Command&quot; )
Set objRS = Server.CreateObject( &quot;ADODB.Recordset&quot; )
objConn.Open someStringyour connectionstring goes here
Set objCmd.ActiveConnection = objConn set the command object's connection to your open connection
objCmd.CommandTimeout = 300 optional: how long should you give the code to execute in seconds
line deleted - wasn't needed
with objCmd
.commandText = &quot;sp_rentEstSearch&quot; put the name of your stored procedure here
.CommandType = adCmdStoredProc must have adovbs included or change value to - &H0004 (w/ no quotes)
Add the values for the parameters that the stored procedure needs here
.parameters(1) = val1
.parameters(2) = val2
.parameters(3) = val3
.parameters(4) = val4
.parameters(5) = val5
End With
set objRS = objCmd.Execute() Execute the stored proc and put the result into the recordset
set objCmd = nothing

for each row in the recordset, add an option to the optionString
optionStr = &quot;<option value=''>Choose One&quot;
DO WHILE NOT objRS.EOF
optionStr = optionStr & &quot;<option value='&quot;& objRS(&quot;value&quot;) &&quot;'>&quot;&objRS(&quot;description&quot;)
objRS.movenext
LOOP
%>
write your option inside of your select list
<select name=&quot;mySelect&quot;><%=optionStr%></select> -- Just trying to help...
[wolf]<--- This is a wolf? We need a new icon.......
mikewolf@tst-us.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top