Recordset or Connection

Results 1 to 2 of 2

Thread: Recordset or Connection

  1. #1
    Join Date
    Dec 1969

    Default Recordset or Connection

    Which is the best option to use<BR>CreateObject(adodb.connection)<BR>or<BR>Cre ateObject(adodb.recordset)<BR>to read all the records from a table<BR>WHat is the difference<BR>

  2. #2 Guest

    Default RE: Recordset or Connection

    For a start it should be "Server.CreateObject".<BR><BR>The connection object defines how the program will access data, so you create a connection object for each database that you want to acces, and set its params ready for use by you script.<BR><BR>The rcordset object uses the connection to acquire data from one or more tables. So having opened a connection at the start of the script, I can open and close recordset via that connection:<BR><BR><BR>set Conn=Server.createobject("ADODB.Connection")<BR>Co nn.Open "{My Connection String}"<BR><BR>set rs1=Server.CreateObject("ABODB.RecordSet")<BR>rs1. Open "Table1", Conn,2,3,2<BR>&#039 Do something with Table1<BR>rs1.Close<BR>set rs1 = Nothing<BR><BR>set rs2=Server.CreateObject("ABODB.RecordSet")<BR>rs2. Open "Table2", Conn,2,3,2<BR>&#039 Do something with Table2<BR>rs2.Close<BR>set rs2 = Nothing<BR><BR>Conn.Close<BR>set Conn = Nothing<BR><BR>I find this method is quite efficient and easy to code. You need worry only once about the connection and I think it is more efficient because you need only make one connection and each recordset uses it. Therefore I would say in conclusion that you should use both objects. If you happen to use only one RecordSet in your page you have lost nothing, but if use more you are ahead.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts