Type mismatch
Hi guys
a newbie question:I get a type mismatch when I run this script and don't know why!
Dim objRS
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.ActiveConnection = "dsn=HOSDB"
objRS.Source = "SELECT * FROM Customers WHERE CustomerID=2"
objRS.CursorType = 0
objRS.CursorLocation = 2
objRS.LockType = 1
objRS.Open()
objRS_numRows = 0
'first of all determine whether there are any records
If objRS.EOF Then
Response.Write("No records returned.")
Else
response.Write(RecToTable(objRS)) <---- I get an error here
Here is the function: (from "Begining ASP 3.0")
Function RecToTable(objRS as ADODB.Recordset)
Dim strT
Dim fldF
strT = "<table border='1'><tr align='center'>"
For Each fldF in objRS.Fields
strT = strT & "<td>" & fldF.name & "</td>"
Next
strT = strT & "</tr>"
While Not objRS.EOF
strT = strT & "<tr align='center'>"
For Each fldF in objRS.Fields
strT = strT & "<td>" & fldF.value & "</td>"
Next
strT = strT & "</tr>"
objRS.MoveNext
Wend
strT = strT & "</table>"
response.write(strT)
RecToTable = strT
End Function
If I don't use the function and just print out the values from DB it works fine (i.e. no problem with connection)
TIA
|