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
    olivier Guest

    Default RE: Recordset?

    One of the advantages of the second method that I found is that<BR>rsTemp("field2") = value2<BR>can handle single quote within value2.<BR>E.g.<BR>rsTemp("name") = namefield <BR>rsTemp.Update<BR>If the value of name is o&#039connor, it would not be any problem for ADO.<BR>"INSERT INTO nametable ( name ) VALUES (namefield)"<BR>would give you troubles if namefield contains o&#039connor<BR>

Posting Permissions

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