Results 1 to 2 of 2

Thread: Recordset?

  1. #1
    Join Date
    Dec 1969

    Default Recordset?

    I have been using ASP and ADO for a little over a year now and there is still one thing that I am not really clear on. Can someone help clear this up for me? This is how I normally get data from a database in my ASP pages;<BR><BR>set connTemp=server.createobject("adodb.connection")<B R> myDSN<BR><BR>set rsTemp=connTemp.Execute("select data")<BR>if rsTemp.eof then<BR> response.write "no data"<BR>else<BR> put loop code here<BR>end if<BR><BR>Now, I don&#039t have any problems with using this code, but all over the place I see code like this to do the same thing;<BR><BR>set connTemp=server.createobject("adodb.connection")<B R>set connTemp=server.createobject("adodb.recordset")<BR > myDSN<BR><BR> "select data",connTemp,1,2<BR>if rsTemp.eof then<BR> response.write "no data"<BR>else<BR> put loop code here<BR>end if<BR><BR>So my question is, why would I use the second method instead of the first? I have used the second method before, but only when I needed to page through the results. Another thing is for inserting new records. I usually just do this;<BR><BR>rsTemp = connTemp.execute("insert here")<BR><BR>But I see others do this;<BR><BR>rsTemp.AddNew<BR>rsTemp("field1") = value1<BR>rsTemp("field2") = value2<BR>rsTemp.Update<BR><BR>So why would I use the second method again instead of the first?<BR><BR>Thanks for any help you may provide.

  2. #2
    Join Date
    Dec 1969

    Default RE: Recordset?

    The second way uses cursors I am not really sure of a good explaination for the cursors but it works better and alot of time if you need to get a record count you need to set the cursor<BR><BR>the third way makes it easier to add records to a table with out worry of special sql characters I find that doing inserts and updates is more reliable the third method <BR><BR>to do updates just open your recordset and leave off the AddNew<BR><BR>rsTemp("field1") = value1<BR>rsTemp("field2") = value2<BR>rsTemp.Update<BR><BR>if I am just doing a select I use an Sql statement<BR><BR>Hope that helped a little

Posting Permissions

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