Click to See Complete Forum and Search --> : dynamic drop down


jmaresca2005
12-09-2004, 11:36 AM
i am attempting to populate a drop down with a list of customers from a db. i get this error: Microsoft VBScript compilation error '800a0400'

Expected statement

/Users/Search.asp, line 26

("@ShipToName",adChar,adParamInput,,Cstr(Request.Form("compDD"))

ANY HELP?

Here is my code:

<%@ Language=VBScript %>

<%

Const adChar = 129


Dim objConn
Dim objCmd
Dim objRS


Set objConn = CreateObject("ADODB.Connection")
objConn.Open Application("Conn_ConnectionString")

If Request.Form("Search") <> "" Then
IF Cstr(Request.Form("compDD")) > 0 then

Set objCmd=Server.CreateObject("ADODB.Command")
objCmd.ActiveConnection=objConn

objCmd.CommandText="_SP_Customers"
objCmd.CommandType=4

objCmdParameters.Append objCmd.CreateParameter
("@ShipToName",adChar,adParamInput,,Cstr(Request.Form("compDD"))

set objRS = objCmd.Execute

%>

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function blockError(){return true;}
window.onerror = blockError;
// End -->
</script>
</head>

<body>
<FORM name="form" action="SearchResults.asp" method="post" onSubmit="return check()" target="_new">
<table>
<tr bgcolor=Thistle>
<td>Great Plains Item Number <input type="text" name="GPITEM"></td>
</tr>
<tr bgcolor=Thistle>
<td align=right>Expected Ship Date mm/dd/yyyy<input type="text" name="EXPSHIP"></td>
</tr>
<tr bgcolor=Thistle>
<td align=right>


<%

Do until objRS.EOF %>
<select name="compDD">
<option value="0">- Please Select a Customer -</option>
<option value="<%trim(objRS.fields("ShipToName"))%>">
<%'=objRS.fields("ShipToName")%>
</option>

<%objRS.MoveNext%>
<%Loop%>
<%end if%>
<%end if%>
</td>
</tr>
</table>
<BR><CENTER>
<input type="hidden" name="Search" Value="1">
<INPUT TYPE="submit" value="Search" ><input type="reset" value=" Clear ">
</CENTER>
</FORM>
</body>
</html>

russell
12-09-2004, 01:27 PM
this needs to be on one line, and you missed a dot

objCmdParameters.Append objCmd.CreateParameter
("@ShipToName",adChar,adParamInput,,Cstr(Request.Form("compDD"))


objCmd.Parameters.Append objCmd.CreateParameter("@ShipToName",adChar,adParamInput,,Cstr(Request.Form("compDD"))

Actually, can clean up a little like this

Set cmd = Server.CreateObject("ADODB.Command")
Set rs = Server.CreateObject("ADODB.Recordset")
With cmd
.ActiveConnection=objConn
.CommandType=4
.CommandText="_SP_Customers"

.Parameters.Append .CreateParameter("@ShipToName",adChar,adParamInput,,Cstr(Request.Form("compDD"))

rs.open .Execute
End With
...

Don't forget to close and destroy the objects when you're done

jmaresca2005
12-09-2004, 01:43 PM
thanks!!!