Jump to content

ADO record set question


Splurd

Recommended Posts

Ok, I've doing something basic

<%'Dimension variablesDim adoCon    'Holds the Database Connection ObjectDim rsGuestbook 	 'Holds the recordset for the records in the databaseDim strSQL 	 'Holds the SQL query for the database'Create an ADO connection odjectSet adoCon = Server.CreateObject("ADODB.Connection")'Set an active connection to the Connection object using a DSN-less connectionadoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("guestbook.mdb")'Create an ADO recordset objectSet rsGuestbook = Server.CreateObject("ADODB.Recordset")'Initialise the strSQL variable with an SQL statement to query the databasestrSQL = "SELECT * FROM table;"'Open the recordset with the SQL query rsGuestbook.Open strSQL, adoCon'Loop through the recordset'blahblahLoop'Reset server objectsrsGuestbook.CloseSet rsGuestbook = NothingSet adoCon = Nothing%>

Thats abit of copypasta of code from a tutorial.Right now, I am updating it, and I am finding I have to do1) do a select * from table 2)after using this record set to populate some stuff, (and form the next sql statement)3) do a select z,y,x from table where a=b,c=d4)Use this to populate a table.So how do I do that, effectivly. Like do I close the record set then re-open it with the next sqlstatement?

Link to comment
Share on other sites

Hi,After the first SQL statement is done then to clear the recordsetRS.Close Set RS = Nothing'then write the new querySQL="SELECT x,y,z FROM tlb_name WHERE a=b AND b=cSet RS = Server.CreateObject("ADODB.Recordset")RS.Open SQL, MyConn'continue populating the tables.....HTH..

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...