IIS ASP - populate dropdown from sproc

This is Interesting: Free IT Magazines  
Home > Archive > IIS ASP > July 2007 > populate dropdown from sproc





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author populate dropdown from sproc
Mike P

2007-07-24, 1:24 pm

I am trying to populate a dropdown from a stored procedure, but I am
getting the error 'Object doesn't support this property or method:
'Next' :

<!--#include file="include_connection.asp"-->
<!--#include file="adovbs.inc"-->

<%

set objConn = server.createobject("adodb.connection")
objConn.open strConnection

%>
<table>
<form>
<tr>
<td bgcolor="cccccc" align="center"><nobr><b>Client</nobr></td>
<td bgcolor="cccccc" align="center"><nobr><b>BDD</nobr></td>
<td bgcolor="cccccc" align="center"><nobr><b>Status</nobr></td>
<td bgcolor="cccccc" align="center"><nobr><b>Meeting
Date</nobr></td>
<td bgcolor="cccccc" align="center"><nobr><b>Brief
Received</nobr></td>
<td bgcolor="cccccc" align="center"><nobr><b>Response
Submitted</nobr></td>
<td bgcolor="cccccc" align="center"><nobr><b>Site Visit</nobr></td>
<td bgcolor="cccccc" align="center"><nobr><b>Decision
Due</nobr></td>
<td bgcolor="cccccc" align="center"><nobr><b>Sign Off
Status</nobr></td>
<td bgcolor="cccccc" align="center"><nobr><b>Sign Off
Month</nobr></td>
<td bgcolor="cccccc" align="center"><nobr><b>Go Live</nobr></td>
<td bgcolor="cccccc" align="center"><nobr><b>Activity
Type</nobr></td>
<td bgcolor="cccccc" align="center"><nobr><b>Description</nobr></td>
<td bgcolor="cccccc" align="center"><nobr><b>Number of
Seats</nobr></td>
<td bgcolor="cccccc" align="center"><nobr><b>Commercials</nobr></td>
<td bgcolor="cccccc" align="center"><nobr><b>Duration</nobr></td>
<td bgcolor="cccccc" align="center"><nobr><b>Comments</nobr></td>
</tr>
<tr>
<td bgcolor="cccccc" align="center"><nobr>
<select name=CompanyNames>
<%
set objCmd = server.CreateObject("ADODB.Command")
objCmd.ActiveConnection = strConnection
objCmd.CommandType = adCmdStoredProc
objCmd.CommandText = "GetCompanyNames"
set rsCompanyNames = objCmd.Execute

do while not rsCompanyNames.eof

'if a code has been selected, set it as selected

Response.Write "<option value=" &
rsCompanyNames("companysitekey") & " >"& rsCompanyNames("name")
&"</option>"

rsCompanyNames.Next

loop

set rsCompanyNames = nothing
set objCmd = nothing
%>
</select>
</nobr></td>
<td>BDD</td>
<td></td>
</tr>
</form>
</table>

Can anybody help?



*** Sent via Developersdex http://www.codecomments.com ***
Bob Barrows [MVP]

2007-07-24, 1:24 pm

Mike P wrote:
> I am trying to populate a dropdown from a stored procedure, but I am
> getting the error 'Object doesn't support this property or method:
> 'Next' :


Please don't multipost. This question was answered in the vbscrpt group you
posted to.

There is no method called Next. It's "MoveNext"


Your code would probably be more efficient if you used Getrows to move the
data into an array, allowing you to close your recordset and database
connection much sooner.

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


Adrienne Boswell

2007-07-31, 1:22 am

Gazing into my crystal ball I observed Mike P <mike.parr@gmail.com>
writing in news:O#wBTYfzHHA.5092@TK2MSFTNGP04.phx.gbl:

> I am trying to populate a dropdown from a stored procedure, but I am
> getting the error 'Object doesn't support this property or method:
> 'Next' :
>
><!--#include file="include_connection.asp"-->
><!--#include file="adovbs.inc"-->
>
><%
>
> set objConn = server.createobject("adodb.connection")
> objConn.open strConnection
>
> %>
><table>
><form>


This is OT, but a table, this is bad HTML. The only element that can come
after a table element is CAPTION, THEAD, COL, COLGROUP or TR. The proper
way is FORM then TABLE.

><tr>
> <td bgcolor="cccccc"
> align="center"><nobr><b>Client</nobr></td>


Save yourself some time, use the right tools for the job:
<th>Field Title</th> - th is natively bold and centered.
and in the CSS:
th {background-color:#CCC; white-space: nobreak}

> <select name=CompanyNames>
> <%
> set rsCompanyNames = objCmd.Execute
>
> do while not rsCompanyNames.eof
>
> 'if a code has been selected, set it as
> selected
>
> Response.Write "<option value=" &
> rsCompanyNames("companysitekey") & " >"& rsCompanyNames("name")
> &"</option>"
>
> rsCompanyNames.Next

rscompanynames.MOVENext
>
> loop
>
> set rsCompanyNames = nothing
> set objCmd = nothing
> %>
>
> Can anybody help?


You would also do better to put this into an array - look up getrows().
Additionally, you might save yourself some time if you used cleaner markup
- have a look at http://intraproducts.com/usenet/requiredform.asp
--
Adrienne Boswell at Home
Arbpen Web Site Design Services
http://www.cavalcade-of-coding.info
Please respond to the group so others can share

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com