Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Snitz Forums 2000 MOD-Group
 MOD Add-On Forum (W/Code)
 Will not open a recordset...
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

beerman
Starting Member

10 Posts

Posted - 28 April 2004 :  22:36:48  Show Profile
I'm getting ready to throw this thing out the window.

I'm developing a mod where people can list cars they own or have owned in the past. I have added the needed tables and have verified that they, and the testing data, are in the database.

I'm building a form within the pop_profile.asp page for people to list their cars. The form will use its own handler and redirect the user back to their profile editing page.

The function is called within DisplayProfile, just after the signature editing form.

It's like the code reads "Exit Function" instead of "recordset.open":

FUNCTION CarForm()
	DIM rsAutos
	RESPONSE.WRITE "<tr>"
	RESPONSE.WRITE "<td colspan=""2"">"
	RESPONSE.WRITE "Car Form Called! <BR />"
	' Get List of current cars
	strSQL = "SELECT * FROM " _
		& strForumTablePrefix & "MEMBER_CARS " _
		& "WHERE MEMBERID = " & MemberID & ";"
	RESPONSE.WRITE strSQL & "<br />"
	SET rsAutos = SERVER.CREATEOBJECT("ADODB.Recordset")
	response.write "Makes an instance of the recordset. <br />"
	' \/\/\/ Code behaves like "exit function" right here. \/\/\/
	rsAutos.open strSQL, my_conn
	response.write "recordset created! <br />"
	IF rsAutos.EOF OR rsAutos.BOF THEN
		Response.Write "It's Empty! <br />"
	ELSE
		response.write "we have cars! <BR />"
		DO UNTIL rsAutos.EOF
			RESPONSE.WRITE "<p>"
			RESPONSE.WRITE rsAutos("MEMCAR_ID") & "; "
			RESPONSE.WRITE rsAutos("AUTOMOBILE_MODEL") & "; "
			RESPONSE.WRITE rsAutos("AUTOMOBILE_YEAR") & "; "
			RESPONSE.WRITE rsAutos("AUTOMOBILE_NICK") 
			RESPONSE.WRITE "</p>"
			rsAutos.MOVENEXT
		LOOP
	END IF
	rsAutos.CLOSE
	response.write "successfully closed recordset! <br />"
	SET rsAutos = NOTHING
	
	' Form for adding another
	
	' I have to build a database populating page
	RESPONSE.WRITE "</td>"
	RESPONSE.WRITE "</tr>"
END FUNCTION


It seriously just exits right there. I get none of the error messages you'd expect ("Object must be open", etc.) if I comment out the "rsAutos.OPEN strSQL, my_conn" line.

I am down to my last four follicles of hair. Can anyone help?

Nikkol
Forum Moderator

USA
6907 Posts

Posted - 29 April 2004 :  00:08:01  Show Profile
shouldn't it be a sub rather than function? what does the line look like that is calling the function?

Nikkol ~ Help Us Help You | ReadMe | 3.4.03 fixes | security fixes ~
Go to Top of Page

chumbawumba
Junior Member

United Kingdom
304 Posts

Posted - 29 April 2004 :  05:20:27  Show Profile
So, your code seems to be failing on this line: rsAutos.open strSQL, my_conn
which means there is either an error with your SQL, connection or DB.

The line you have that response.writes the sql statement, - copy & paste the outputted string into the query designer in Access and see if it returns anything.

Is your MEMBER_CARS table actually called FORUM_MEMBER_CARS ?


Also, I think this line:
IF rsAutos.EOF OR rsAutos.BOF THEN
should be
IF rsAutos.EOF AND rsAutos.BOF THEN

Do you get any errors whatsoever?

Can't stop, lose job, mind gone, silicon.
Go to Top of Page

beerman
Starting Member

10 Posts

Posted - 29 April 2004 :  11:12:16  Show Profile
Thanks for the responses!

quote:
shouldn't it be a sub rather than function? what does the line look like that is calling the function?

myStts = CarForm()


I might have a use for checking the value of myStts in the future. Changing it to a Sub after I'm done isn't a big deal.

Anyways, it outputs my SQL to HTML and "makes instance of recordset object" to HTML. The code jumps out of the function anytime I reference the recordset object.

quote:
copy & paste the outputted string into the query designer in Access

I don't have a copy of access at home.

quote:
Is your MEMBER_CARS table actually called FORUM_MEMBER_CARS ?
I might have misspelled (or totally missed the mark on) the variable here?:

& strForumTablePrefix & "MEMBER_CARS " _


I don't have the code in front of me, I can't verify what the prefix variable is in the config.asp file right now. I just did it off the top of my head last night.

That's most likely the root of my problems.

THANKS!
Go to Top of Page

beerman
Starting Member

10 Posts

Posted - 30 April 2004 :  00:07:53  Show Profile
The variable should have read strTablePrefix. All is well now.

Thanks for pointing out the obvious!
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.16 seconds. Powered By: Snitz Forums 2000 Version 3.4.07