Leer una BD y cargar la info en un ComboBox en ASP
Tengo arriba:
-----------------------------------
<%
Dim CnnMM, RstMM, SLQ, Cuenta
Set CnnMM=Server.CreateObject("ADODB.Connection")
Set RstMM=Server.CreateObject("ADODB.Recordset")
CnnMM.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("MM.mdb")
RstMM.Open "Select * from Marca", CnnMM
Cuenta = 1
%>
-----------------------------------
Mas abado en el ComboBox tengo:
-----------------------------------
<select size="1" name="CobMarca" style="font-family: Verdana; font-size: 8pt">
<%While Not RstMM.EOF%>
<option value="<%RstMM.Fields("Cod")%>"
<%If Cuenta = 1 Then%>
selected
<%End If%>><%RstMM.Fields("Marca")%></option>
<%Cuenta = Cuenta + 1
RstMM.MoveNext%>
<%Wend
CnnMM.Close%>
</select></font></td>
-----------------------------------
Lo que deseo es Cargar la Infor que esta en la BD "MM" en la tabla "Marca"... El explorer me tira el siguiente error:
=============
Error Type:
Microsoft VBScript runtime (0x800A01C2)
Wrong number of arguments or invalid property assignment:
'Fields'
/Vehiculos.asp, line 63
=============
La línea 63 dice: <option value="<%RstMM.Fields("Cod")%>"
-----------------------------------
<%
Dim CnnMM, RstMM, SLQ, Cuenta
Set CnnMM=Server.CreateObject("ADODB.Connection")
Set RstMM=Server.CreateObject("ADODB.Recordset")
CnnMM.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("MM.mdb")
RstMM.Open "Select * from Marca", CnnMM
Cuenta = 1
%>
-----------------------------------
Mas abado en el ComboBox tengo:
-----------------------------------
<select size="1" name="CobMarca" style="font-family: Verdana; font-size: 8pt">
<%While Not RstMM.EOF%>
<option value="<%RstMM.Fields("Cod")%>"
<%If Cuenta = 1 Then%>
selected
<%End If%>><%RstMM.Fields("Marca")%></option>
<%Cuenta = Cuenta + 1
RstMM.MoveNext%>
<%Wend
CnnMM.Close%>
</select></font></td>
-----------------------------------
Lo que deseo es Cargar la Infor que esta en la BD "MM" en la tabla "Marca"... El explorer me tira el siguiente error:
=============
Error Type:
Microsoft VBScript runtime (0x800A01C2)
Wrong number of arguments or invalid property assignment:
'Fields'
/Vehiculos.asp, line 63
=============
La línea 63 dice: <option value="<%RstMM.Fields("Cod")%>"
<select size="1" name="CobMarca" style="font-family: Verdana; font-size: 8pt">
<%Do While Not RstMM.EOF%>
<option value="<%=RstMM("Cod")%>"<%If Cuenta = 1 Then%> selected<%End If%>><%=RstMM("Marca")%> </option>
<%Cuenta = Cuenta + 1
RstMM.MoveNext%>
<%Loop
CnnMM.Close%>
</select></font></td>
Fijate que he quitado Fields(usa Fields si quieres), es porqué nunca lo pongo, pero creo que te falla porqué te has descuidado el "=" antes del campo que quieres mostrar
<%=variable%> para mostrar una variable
También he cambiado el bucle, y he puesto Do While Not xxxxx.EOF i al final del bucle Loop, para que vuelva.
así lleno los combos:
<select name="tipuscita">
<% Do While Not tipusCita.EOF %>
<OPTION value=<%=tipusCita("idtipus")%>><%=tipusCita("nomtipus")%></OPTION>
<%tipusCita.MoveNext
Loop%>
</select>
tipusCita es el recordset y el value no lleva "" porqué es un campo autonumérico.
prueba a ver si te sirve mi ayuda...
<%Do While Not RstMM.EOF%>
<option value="<%=RstMM("Cod")%>"<%If Cuenta = 1 Then%> selected<%End If%>><%=RstMM("Marca")%> </option>
<%Cuenta = Cuenta + 1
RstMM.MoveNext%>
<%Loop
CnnMM.Close%>
</select></font></td>
Fijate que he quitado Fields(usa Fields si quieres), es porqué nunca lo pongo, pero creo que te falla porqué te has descuidado el "=" antes del campo que quieres mostrar
<%=variable%> para mostrar una variable
También he cambiado el bucle, y he puesto Do While Not xxxxx.EOF i al final del bucle Loop, para que vuelva.
así lleno los combos:
<select name="tipuscita">
<% Do While Not tipusCita.EOF %>
<OPTION value=<%=tipusCita("idtipus")%>><%=tipusCita("nomtipus")%></OPTION>
<%tipusCita.MoveNext
Loop%>
</select>
tipusCita es el recordset y el value no lleva "" porqué es un campo autonumérico.
prueba a ver si te sirve mi ayuda...
<select size="1" name="CobMarca" style="font-family: Verdana; font-size: 8pt">
<%Do While Not RstMM.EOF%>
<option value="<%=RstMM("Cod")%>"<%If Cuenta = 1 Then%> selected<%End If%>><%=RstMM("Marca")%> </option>
<%Cuenta = Cuenta + 1
RstMM.MoveNext%>
<%Loop
CnnMM.Close%>
</select></font></td>
Fijate que he quitado Fields(usa Fields si quieres), es porqué nunca lo pongo, pero creo que te falla porqué te has descuidado el "=" antes del campo que quieres mostrar
<%=variable%> para mostrar una variable
También he cambiado el bucle, y he puesto Do While Not xxxxx.EOF i al final del bucle Loop, para que vuelva.
así lleno los combos:
<select name="tipuscita">
<% Do While Not tipusCita.EOF %>
<OPTION value=<%=tipusCita("idtipus")%>><%=tipusCita("nomtipus")%></OPTION>
<%tipusCita.MoveNext
Loop%>
</select>
tipusCita es el recordset y el value no lleva "" porqué es un campo autonumérico.
prueba a ver si te sirve mi ayuda...
<%Do While Not RstMM.EOF%>
<option value="<%=RstMM("Cod")%>"<%If Cuenta = 1 Then%> selected<%End If%>><%=RstMM("Marca")%> </option>
<%Cuenta = Cuenta + 1
RstMM.MoveNext%>
<%Loop
CnnMM.Close%>
</select></font></td>
Fijate que he quitado Fields(usa Fields si quieres), es porqué nunca lo pongo, pero creo que te falla porqué te has descuidado el "=" antes del campo que quieres mostrar
<%=variable%> para mostrar una variable
También he cambiado el bucle, y he puesto Do While Not xxxxx.EOF i al final del bucle Loop, para que vuelva.
así lleno los combos:
<select name="tipuscita">
<% Do While Not tipusCita.EOF %>
<OPTION value=<%=tipusCita("idtipus")%>><%=tipusCita("nomtipus")%></OPTION>
<%tipusCita.MoveNext
Loop%>
</select>
tipusCita es el recordset y el value no lleva "" porqué es un campo autonumérico.
prueba a ver si te sirve mi ayuda...
