Splurd Posted May 22, 2006 Share Posted May 22, 2006 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 More sharing options...
jojay Posted May 22, 2006 Share Posted May 22, 2006 (edited) I dont understand fully what you are trying to say but if you are trying to update fields then you have to use update statement. Below is a link as example for update statement:http://www.w3schools.com/sql/sql_update.asp Edited May 23, 2006 by aspnetguy Link to comment Share on other sites More sharing options...
Splurd Posted May 23, 2006 Author Share Posted May 23, 2006 when I say updating, I ment I am modifying the code.But, I just want to ask, when I want to do two select statements within 1 asp file, what is the best way to do it. Link to comment Share on other sites More sharing options...
pulpfiction Posted May 23, 2006 Share Posted May 23, 2006 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 More sharing options...
Splurd Posted May 29, 2006 Author Share Posted May 29, 2006 Another question, tho not really a lessonWhat are the curor types and lock types and what do that mean for the record set,http://www.w3schools.com/ado/met_rs_open.asp <-- is what I am talking about, I dont quite understand them, and what should I use. (I see some tutorials useing 1,1, and some using 3,3 etc) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now