Forum Moderators: open

Message Too Old, No Replies

sql server

type mismatch on rs

         

macrost

11:41 pm on Sep 27, 2003 (gmt 0)

10+ Year Member



I have a problem with my asp connection to my sql server. When I try to write out the value of the column id, I get the error of type mismatch 'rs'. id column is a numeric field. Here's the connect code:


<%@ language="vbscript" %>
<%OPTION EXPLICIT%>
<%
'***************************************************
'Create our connection to the sql server, and define our recordsets
'***************************************************

Dim conn, rsmain, strmain
Set conn = Server.CreateObject("ADODB.Connection")
'This connection string is brought to you by microsoft
conn.Open "dsn=mydsn;uid=myuid;pwd=mypwd;DATABASE=database;APP=ASP Script"

strmain = "Select * From dbo.main_watches"
Set rs = Server.CreateObject("ADODB.RecordSet")
rs.Open strmain, conn
While Not rs.EOF
%>


Thanks everyone!

Mac

mattglet

1:23 pm on Sep 28, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



mac-

what line are you erroring at? don't use the recordset object, you'll see better performance if you just use conn.execute(strmain).

i should be available later today if you still need help.

-Matt

plumsauce

6:38 pm on Sep 28, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member





don't use the recordset object, you'll see better performance if you just use conn.execute(strmain).

that sounds interesting!

can you give a small example of how
the data is accessed after the call
returns?

macrost

1:31 pm on Sep 29, 2003 (gmt 0)

10+ Year Member



plumsauce,
Well here's a little tidbit:

Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "yourdsn"
strsql = "Select * from your_table"
Set rs = conn.Execute(strsql)
While Not rs.EOF

And in your page, you can access any field that is contained in rs by this.


<%=rs("column_name")%>
</html>


rs.MoveNext
Wend

Mac

aspdaddy

1:51 pm on Sep 29, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Mac, have you tried converting the value to a string first -
response.write cstr( rs("id") )

Plumsauce, some good info on when not to use a recordset
http*//www.aspfaq.com/show.asp?id=2191

plumsauce

10:19 am on Sep 30, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member




thanks guys.

i just thought there was a way to avoid
the rs object. just fishin' you know.

if they would let me use dblib in asp
i would be such a happy camper ;Q

++++