Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DIM in ASP

Status
Not open for further replies.

edgarv

MIS
Jul 25, 2003
248
US
hello,

I am having some difficulties passing a field in my asp script.
I have an access DB where I have 4 fields username,userid password, link. I have a Dim in my asp script that gets the userid, if I try to add another DIM to get the username, I get an error
ADODB.Recordset error '800a0cc1'

Item cannot be found in the collection corresponding to the requested name or ordinal.
test.asp, line 19
and here is line 19 salesrep=rs("username")

here is what my code looks like

Username = Request.Form("txtUsername")
Password = Request.Form("txtPassword")

'Build connection with database
set conn = server.CreateObject ("ADODB.Connection")
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.MapPath ("test.mdb")
set rs = server.CreateObject ("ADODB.Recordset")

'rs.Open "SELECT userid FROM yourtable Where Where FECHNB='" & Session("Username")& "'", conn
rs.Open "SELECT userid FROM userlist where username='" & Session("Username")& "'", conn, 1
Dim presentuserid

presentuserid=rs("userid")

dim salesrep

salesrep=rs("username")




set conn = server.CreateObject ("ADODB.Connection")
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.MapPath ("stats.mdb")
set rs = server.CreateObject ("ADODB.Recordset")

conn.Execute "Insert into log (commission ) VALUES ('" & salesrep & "' )"



the test.db is where my username password userid link are stored and the stats.mbd is where I am trying to insert the username. I can isert the userid but not the user name


help please!!
 
Are you sure that there is a field in the recordset named "username"?

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
rs.Open "SELECT userid FROM userlist where username='" & Session("Username")& "'", conn, 1

you're not actually returning the username in your recordset .....
 
can I add an rs.Open "Select username From userlist where username='" & Session("Username")& "'", conn, 1


sorry for the ignorance I am new at programming
 
yes - you do it like this...
Code:
rs.Open "SELECT userid, username FROM userlist where username='" & Session("Username")& "'", conn, 1
Basically, any fields that you want to make use of in your code need to be included in your recordset. This is done in the SELECT statement above.

Tony
________________________________________________________________________________
 
Code:
 rs.Open "SELECT userid,username FROM userlist where username='" & Session("Username")& "'", conn, 1


Chris.

Indifference will be the downfall of mankind, but who cares?
A website that proves the cobblers kids adage.
Nightclub counting systems

So long, and thanks for all the fish.
 
I tried that and I get and error

ADODB.Recordset error '800a0e79'

Operation is not allowed when the object is open.

test.asp, line 13
here is line 13
rs.Open "SELECT username FROM userlist where username='" & Session("Username")& "'", conn, 1

here is my code

Username = Request.Form("txtUsername")
Password = Request.Form("txtPassword")

'Build connection with database
set conn = server.CreateObject ("ADODB.Connection")
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.MapPath ("test.mdb")
set rs = server.CreateObject ("ADODB.Recordset")

'rs.Open "SELECT userid FROM yourtable Where Where FECHNB='" & Session("Username")& "'", conn
rs.Open "SELECT userid FROM userlist where username='" & Session("Username")& "'", conn, 1
rs.Open "SELECT username FROM userlist where username='" & Session("Username")& "'", conn, 1

Dim presentuserid

presentuserid=rs("userid")

dim salesrep

salesrep=rs("name")




set conn = server.CreateObject ("ADODB.Connection")
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.MapPath ("stats.mdb")
set rs = server.CreateObject ("ADODB.Recordset")

conn.Execute "Insert into log (commission ) VALUES ('" & salesrep & "' )"




thanks
 
Use the Select statements that were shown above. recordset opens are not cumulative. If you want more than one field in your recordset, then you must select more than one field in one select statement.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Thank you so very much for all your help, it has been great.



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top