-1

I'm trying to display a distinct set of values in a form. When I use a number field all works fine. When trying to use a string field, I get this error.

Microsoft VBScript runtime error '800a000d'
Type mismatch: 'QRs(...)'
/RAY-QUICK.asp, line 92


<option selected value="0"> - Ft_ProdCode - SQL tekst  </option>
<% ' -----------------------------------------------   START SQL QUERY
Set MyConn = Server.CreateObject("ADODB.Connection") 
MdbFilePath = Server.MapPath("/db/quickd.mdb") 
MyConn.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & MdbFilePath & ";"

SQL_Query = "SELECT DISTINCT Quick.[Ft_ProdCode] FROM Quick;"

Set RS = MyConn.Execute(SQL_query) 
If Not Rs.EOF Then
    QRs = Rs.GetRows()
        QaantVelden = UBound(QRs):QaantRecords = UBound(QRs, 2)
Else
    AnaantRecords = -1
End If

Rs.Close
Set Rs = Nothing
myConn.Close
Set myConn = Nothing

DeCEL=0 : do while DeCEL<>Qaantrecords+1
    if QRS(0,deCEL )>0 then
        %>
        <option value="<%=QRS(0,deCEL )%>"><%=QRS(0,deCEL )%></option>
        <%  end if
    DeCEL=DeCEL+1 : loop : DeCEL=0

%>
</select>
0

1 Answer 1

0

Try doing away with the array logic and just loop the rs instead:

Set MyConn = Server.CreateObject("ADODB.Connection") 
MdbFilePath = Server.MapPath("/db/quickd.mdb") 
MyConn.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & MdbFilePath & ";"

Set RS = MyConn.Execute("SELECT DISTINCT Quick.[Ft_ProdCode] FROM Quick;") 

do while not RS.eof
    response.write("<option value=""" & RS("Ft_ProdCode") & """>" & RS("Ft_ProdCode") & "</option>")
    RS.movenext
loop

Rs.Close
Set Rs = Nothing
myConn.Close
Set myConn = Nothing
3
  • Don't encourage this the ADODB.Recordset object is a blimp as it is, GetRows() and Close() should be the most used methods when working with ADODB.Recordset unless you want to do something 99.89% of people don't.
    – user692942
    Jan 27, 2015 at 13:48
  • It's pointless helping when people just want a "quick fix". Good luck when you actually try this with a SQL Server and million or so records.
    – user692942
    Jan 27, 2015 at 14:22
  • He's outputting a few <option> tags & clearly won’t be looping a million or so records in this instance - both will execute < 1ms. If you want to help him preserve array use feel free to post an answer of your own & stop nitpicking.
    – HeavenCore
    Jan 27, 2015 at 14:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.