Click to See Complete Forum and Search --> : simple piece of code - need help


kmckil.ca4
May 17th, 2001, 03:18 PM
hi,

this is the code

var UID = objConn.execute("select UID from Tbl_users where EmailName='"+strEmailAddr+"'");
Response.write(UID);

it gives an error at the Response.write line, saying:
Response object error 'ASP 0185 : 8002000e'

Missing Default Property

A default property was not found for the object.


UID is an auto-number in my sql database, and strEmailAddr is a varchar.
I've tested the sql with query analyzer and it works fine (ie there is a UID value for the particular email address I check), but it doesn't work from my asp page.

Any ideas?

Trojahn
May 17th, 2001, 05:17 PM
If think this will not work cause you trying to set a var with a recordset... Try to declare UID as and ADODB.Recordset and use
UID.open "sql command"
and then use
response.write(UID("datafield"))

That's it..

kmckil.ca4
May 18th, 2001, 05:53 AM
tried this:

var RS = Server.CreateObject("ADODB.Recordset");
RS.Open("select * from Tbl_users where EmailName='"+strEmailAddr+"'");

Response.write(RS("UID"));







It didn't work - gave the following error:


ADODB.Recordset error '800a0e7d'

The application requested an operation on an object with a reference to a closed or invalid Connection object.


what am I doing wrong?

Trojahn
May 18th, 2001, 10:13 AM
I didn't tested it but, the right way is...


Dim rs, conn

set conn = Server.CreateObject("ADODB.Connection")
set rs = Server.CreateObject("ADODB.Recordset")

'Change it to your connection string
conn.open "Driver=Microsoft Access Driver (*.mdb);DBQ=your_bd_here.mdb"
rs.open "select * (......)", conn

response.write(rs("UID"))




I think it will work... You only must pay attention to the connection string you'll use.

kmckil.ca4
May 18th, 2001, 10:27 AM
what's the javascript equivalent of:
set RS = .........

I've been looking, but I all the examples I can find are in vbscript!

also, I have my conn.open done already above the piece of code I gave - I don't need to do it again do I?