Re: Lookup executes 3 time upon Recordset.Save



Finally found the problem after wasting around 5 hours. The problem occurs
because the recordset is using a server side cursor, I have switched to a
client side cursor and the SQL is now only executed once.

The performance hit of using a client side cursor is much less than
executing my code three times (the code below is simplified fro
demonstration purposes, my actual SQL creates a temp table, selects data
into from a join of around ten tables, paginates and returns the result,
drops the temp table, and finally stores some usage stats).

I have learnt from this problem that one must be VERY careful to check
performance issues when using Recordset.Save

Julian


"Julian Madle" <julian@xxxxxxxxxxxxxxxx> wrote in message
news:uBArxraJGHA.2064@xxxxxxxxxxxxxxxxxxxxxxx
> Getting really strange problem using Recordset.Save: my SQL command gets
> executed three times (tested on SQL Server 2000 and 2005 using both
> sqloledb
> and {SQL Server} drivers):
>
> Set objConn = Server.CreateObject("ADODB.Connection")
> objConn.Open("Driver={SQL Server}; Server=localhost; Database=DBname; User
> ID=Username; Password='password'")
> Set RS = objConn.Execute("SET NOCOUNT ON; SELECT ID FROM Products; INSERT
> INTO DebugLog (Message) VALUES ('Done'); SET NOCOUNT OFF")
> RS.Save "c:\output.xml", 1
> Set RS = Nothing
> objConn.Close
> Set objConn = Nothing
>
> When executed (once) there will be three 'Done' messages in the table
> named
> DebugLog. This does not occur when the (exetremly simplified) SQL is
> executed directly inside SQL Server, or when RS.Save is not called. This
> looks like a bug in ADO to me.
>
> Can anybody confirm this behaviour and more importantly suggest a
> solution/workaround?
>
>
> Thanks
> Julian
>


.



Relevant Pages

  • Re: Millions of Delete Statements
    ... You mention a cursor. ... Others have mentioned batching the commands, ... so I will throw out one that is less good (executing them ... get the whole SQL statement I don't know of another way to do it). ...
    (comp.databases.ms-sqlserver)
  • Re: Daten schnell lesen =?ISO-8859-1?Q?=28Gegenst=FCck_zu_BU?= =?ISO-8859-1?Q?LK_INS
    ... Damit meinte ich eine direkte Verarbeitung mittels ... 10maligem FETCH (näheres findest Du unter DECLARE CURSOR). ... Ein DataReader in einer SQL Server Assembly ist ... Anweisungen auf dem Server erledigt werden kann. ...
    (microsoft.public.de.sqlserver)
  • Re: Geschwindigkeit optimieren ADO
    ... öffnen mit jeweils anderem SQL String ... -SQL Server Stored Procedure mit Command Objekt aufrufen-> Recordset ... adOpenForwardOnly, adLockReadOnly, auch mal Firehose Cursor genannt. ...
    (microsoft.public.de.sqlserver)
  • Re: 0x800a0cb3 when Update record
    ... the SQL statement are... ... The only cursor type allowed with client-side ... let SQL Server take care of your transactions for you: ...
    (microsoft.public.data.ado)
  • RE: OLE DB Provider - how tell to not use cursor internally for jo
    ... from server to client. ... me under SQL 2000 error, because DBE OLE provider use cursor for join tables. ... Under SQL 7.0 it run well, the cursor isn't use for join tables. ...
    (microsoft.public.sqlserver.programming)