Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 15th, 2004, 07:31 PM
Registered User
 
Join Date: Nov 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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

 
Old November 15th, 2004, 07:53 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

Try Changing this line:
Function RecToTable(objRS as ADODB.Recordset)
to:
Function RecToTable(objRS)



Wind is your friend
Matt
 
Old November 16th, 2004, 03:16 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Yes, you can't define that as a ADODB.RECORDSET type in ASP;) as it is all treated as variant.

Matt was right there.

_________________________
- Vijay G
Strive for Perfection





Similar Threads
Thread Thread Starter Forum Replies Last Post
type mismatch frresh Pro Visual Basic 2005 1 April 11th, 2006 08:35 AM
Type Mismatch Anup Gavate VB How-To 4 March 28th, 2005 01:48 PM
Type mismatch per.holleufer Classic ASP Basics 5 July 31st, 2004 07:33 AM
Type mismatch sporkman43 Classic ASP Basics 4 August 14th, 2003 03:27 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.