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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Object Required Error, Do While Not Statement 1

Status
Not open for further replies.

Airpan

Technical User
Jun 14, 2005
172
US
I am getting this error:
Object required: '', line 18
Line 18 is:
Code:
Do While Not rec.EOF

If additional code is needed I can supply it.

~E
 
Can you post the code around it and also where you define rec?


[monkey][snake] <.
 
Monksnake,
Here is the code around it:
Code:
Dim Con, sql, rec
set Con = Server.CreateObject("ADODB.Connection")
Con.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("db/logins.mdb")
UserID = Session("sesUserName")
SQL = "SELECT * FROM cust_logins WHERE [USERNAME]= '"& UserID &"' "
'response.write(sql)
Response.Write("<table border=1><tr><th>CustName</th><th>Cuser</th><th>CPass</th><th>Email</th></tr>")
	Do While Not rec.EOF
Response.Write("<tr>")
Response.Write("<td>")
Response.Write(rec("CustName"))
Response.Write("</td>")
Response.Write("<td>")
Response.Write(rec("USERNAME"))
Response.Write("</td>")
Response.Write("<td>")
Response.Write(rec("USERPASS"))
Response.Write("</td>")
Response.Write("<td>")
Response.Write(rec("Email"))
Response.Write("</td>")
Response.Write("</tr>")
Response.Write("</table>")
rec.MoveNext
Loop
Con.Close  
%>
The session variable code is above it:
Code:
<%Session("sesUserName")=Request.Form("username")%>
<%=Response.Write("Welcome ")%>
<%= Response.Write(Session("sesUserName"))%>

~E
 
Monksnake,
monksnake said:
you are not opening not closing the recordset.[/quote monksnake]
Are you saying that I am not closing the recordset?
I corrected it like so:
Code:
set Con = Server.CreateObject("ADODB.Connection")
set rec=Server.CreateObject("ADODB.Recordset")
I then put the closing statement at the bottom like so:
Code:
rec.MoveNext
Loop
Con.Close 
Rec.close
The error it generates is:Operation is not allowed when the object is closed.line 19
Line 19 is
Code:
Do While Not rec.EOF
I apologize if I am not getting it. Thanks for link, I read it and am still reading it.

~E
 
You are not opening the recordset either, that has to be done first.

On this part
Code:
rec.MoveNext
Loop
Con.Close 
Rec.close

You are calling the recordset [!]r[/!]ec and you should close the recordset before closing the connection.


Code:
rec.MoveNext
Loop
rec.close 
Con.Close




[monkey][snake] <.
 
here's a snippet of code showing the opening of a recordset via a query.

Code:
set rec = Server.CreateObject("ADODB.recordset")
rec.Open "Select * from Customers", Con


[monkey][snake] <.
 
AHHHHHH! Somehow I told you so, just doesn't cut it does it? lol. Thanks MonkSnake will give that a shot. I will now go put on my duntz hat and sit in the corner.

~E
 
I make real stupid mistakes all the time. In fact, some of my posts on Tek-Tips are just plain bad and after I post them I feel like an idiot.

If you have any questions after setting that up, feel free to ask.

[monkey][snake] <.
 
MonkSnake,
Well, after I CAREFULLY read through my code I realized that I had copied and pasted my connection code from another page, and that page was missing parts. So I had just been copying the wrong stuff for the past three pages. *sigh*
At any rate, here is the code I had originally, which was working, and thus I couldn't figure out why it wouldn't run (thinking that I had just gotten it to work on the page I had copied it from). Enough rambling... you get the picture.
Thanks again for catching that and here is what I had initially before I got copy and paste happy:
Code:
   Dim Con, sql, rec
   set Con = Server.CreateObject("ADODB.Connection")
   Con.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("db/logins.mdb")
   UserID = Session("sessUserName")
     SQL = "SELECT * FROM custlogins WHERE [USERNAME]= '"& UserID &"' "
 set rec=Con.execute(sql)

~E
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top