Problem using SQLExecute when calling stored procedure

From: Prakash (anonymous_at_discussions.microsoft.com)
Date: 05/21/04


Date: Fri, 21 May 2004 09:21:06 -0700

Hi!

I am having problem using SQLExecute for calling stored procedures in a loop (for SQL server). Following is how I coded:

sqlReturn = SQLAllocHandle(SQL_HANDLE_STMT, ....);
sqlReturn = SQLPrepare(sqlStatement,....);

sqlReturn = SQLBindParameter(sqlStatement,....);
sqlReturn = SQLBindParameter(sqlStatement,....);

for (lIndex = 0; lIndex < 100; lIndex++)
{
    GetData(...);
    sqlReturn = SQLExecute(sqlStatement,....);
 }

The loop executed fine once, but fails the second time. The sql return code is -1, and diag record returns Invalid cursor state...The above works fine for Oracle database, but returns error for SQL server.

Any help is highly appreciated....

Thank you.



Relevant Pages

  • Re: ADO Recordset Update & SQL Server 2005 ??
    ... I've tried explicit .Update inside the loop and outside the loop as a batch ... There's no 500 error (asp and iis 6) posted on the page. ... This error shows up ONLY when connected to a sql server 2005 server. ... the same database schema/data in sql server 2005, ...
    (microsoft.public.data.ado)
  • Re: DTS Workflow Question
    ... >I am using SQL Server 2000 and I am writing a DTS package that loops ... >Script handling the loop routine. ... You could duplicate the ActiveX Script to restart the loop, ... Darren Green (SQL Server MVP) ...
    (microsoft.public.sqlserver.dts)
  • Re: Vlookup nightmare
    ... >excel can _NOT_ do loops like SQL can. ... >SQL Server can loop through using a cursor. ... Procedural code can loop through a cursor into a dbms table. ... But for those not so few who have MSFT Office ...
    (microsoft.public.excel)
  • Re: Ideas on running a large UPDATE causing Locks...
    ... >Yep, it's a loop. ... >Columnist, SQL Server Professional ... >>SQL Server MVP ... >>Toronto, ON Canada ...
    (microsoft.public.sqlserver.server)
  • Re: Ideas on running a large UPDATE causing Locks...
    ... Columnist, SQL Server Professional ... www.pinnaclepublishing.com/sql "Roz" wrote in message ... I imagine I'd do this in a loop? ... you are not blocking too many>users at a time. ...
    (microsoft.public.sqlserver.server)