when to use the command obj vs recordset obj

Results 1 to 2 of 2

Thread: when to use the command obj vs recordset obj

  1. #1
    stephen of new york Guest

    Default when to use the command obj vs recordset obj

    can someone please tell all the different situations when one would rather use the command object instead of the recordset object.<BR><BR>I&#039m under the impression that one time would be when you have an asp page in which you are constantly closing and reopening the recordset to execute different queries as below:<BR><BR>sqlstatement1=whatever<BR>rs.open sqlstatement1, conn, 0<BR>rs.close<BR><BR>sqlstatement2=whatever<BR>rs. open sqlstatement2, conn, 0<BR>rs.close<BR><BR>sqlstatement3=whatever<BR>rs. open sqlstatement3, conn, 0<BR>rs.close<BR><BR>sqlstatement4=whatever<BR>rs. open sqlstatement4, conn, 0<BR>rs.close<BR><BR>sqlstatement5=whatever<BR>rs. open sqlstatement5, conn, 0<BR>rs.close<BR><BR>sqlstatement6=whatever<BR>rs. open sqlstatement6, conn, 0<BR>rs.close<BR><BR>Is this a sitation where one would use the command object. <BR>if so PLEASE TYPE THE SYNTAX FOR USING THE COMMAND OBJECT IN THIS SITUATION.<BR><BR>2. can someone please provide some other different situations.<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: when to use the command obj vs recordset obj

    I don&#039t use command objects. There&#039s rarely a good reason to use them. You can accomplish almost everything with straight connection and recordset objects. I&#039ve yet to see a SQL operation that required the use of a command object.<BR><BR>If you&#039re using SQL Server (6.5 or 7, at least) you could use the following code to open the recordsets:<BR><BR>&#060;%<BR>strSQL=sqlstatement1 & ";" & sqlstatement2 & ";" & sqlstatement3 & ";" & _<BR>sqlstatement4 & ";" & sqlstatement5 & ";" & sqlstatement6<BR>rs.open conn.Execute(strSQL)<BR>&#039rs() now refers to the recordset returned by the first SQL comand<BR>&#039rs.NextRecordset will move you to the second recordset<BR>&#039and so on.<BR>%&#062;<BR><BR>Kurt

Posting Permissions

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