populate dropdown from sproc

M

Mike P

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?
 
B

Bob Barrows [MVP]

Mike said:
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.
 
A

Adrienne Boswell

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,177
Latest member
OrderGlucea
Top