Results 1 to 2 of 2

Thread: adodb.connection

  1. #1
    Join Date
    Dec 1969

    Default adodb.connection

    **Please note my question below this code snippet:**<BR><BR>&#060;% &#039;SPECIFY THE PROVIDER<BR> strProvider="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("foodhouse") & "foodinventory.mdb;"<BR> <BR> &#039;CREATE CONNECTION OBJECT AND OPEN IT <BR>set Conn = Server.CreateObject("ADODB.Connection")<BR>Conn.Op en strProvider<BR> <BR> <BR> &#039;CREATE RECORD SET OBJECT<BR>set rs = Server.createobject("adodb.recordset")<BR> <BR> &#039;SQL QUERY<BR>strSQL = "SELECT steaks FROM foodinfo"<BR> <BR> &#039;OPEN RECORD SET OBJECT<BR>rs.Open strSQL, conn, , , adCmdText <BR>rowcount=0<BR>%&#062;<BR><BR><BR><BR>========= ========<BR>QUESTION: I&#039;ve noticed that I can leave off the "CREATE CONNECTION OBJECT part and instead, reference the "strProvider" directly in the "OPEN RECORD SET OBJECT" area. <BR><BR>So...this: <BR>rs.Open strSQL, strProvider, , , adCmdText. <BR><BR>Gives me the same result as this: <BR>rs.Open strSQL, conn, , , adCmdText. <BR><BR>Can someone explain why I need a CONNECTION OBJECT statement?<BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: adodb.connection

    yes, it is possible to use literals but :<BR><BR>1. it&#039;s good programming paractice to have a reference available to the connection object, in case you need to use it more than once.<BR>2. if you have a reference, you can close() it and clean it up manually, without having to wait an age for the garbage collection routine to do it for you, thus freeing up resources<BR><BR>j

Posting Permissions

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