Skip to Content.
Sympa Menu

freetds - [freetds] Two statements on one connection

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "cui yanxin" <cuiyanxin AT hotmail.com>
  • To: freetds AT lists.ibiblio.org
  • Subject: [freetds] Two statements on one connection
  • Date: Fri, 02 Dec 2005 06:16:20 +0000



Dear All,

I am using freeTDS 0.63 and unixODBC under Redhat 7.1. Is it OK to use two statements on one connection? The below code gives me 'invalid cursor state' error while trying to do the second SQLExexDirect(). The code works fine for Oracle and MySQL drivers. What should I do if I want to achieve the below goal(e.g. fetch one table inside loopof fetching another table)?


.......
V_OD_erg=SQLExecDirect(V_OD_hstmt,"select employeeid,firstname,hiredate,
salary,dsc FROM employees", SQL_NTS);
SQLAllocHandle(SQL_HANDLE_STMT, V_OD_hdbc, &V_OD_hstmt2);
SQLBindCol(V_OD_hstmt2,1,SQL_C_CHAR,&V_OD_buffer2,150,&V_OD_err);
V_OD_erg=SQLExecDirect(V_OD_hstmt2,"select firstname from table2 ", SQL_NTS);
V_OD_erg=SQLFetch(V_OD_hstmt);
while(V_OD_erg != SQL_NO_DATA)
{
printf("row(%d) Result: [%d] [%s] [%s] [%f] [%s]\n",
i,V_OD_id,V_OD_buffer,V_OD_date,V_OD_double,V_OD_dsc);
V_OD_erg=SQLFetch(V_OD_hstmt2);
printf("second Result: [%s]\n", V_OD_buffer2 );
V_OD_erg=SQLFetch(V_OD_hstmt);
i++;
};

Regards

Yanxin

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/





Archive powered by MHonArc 2.6.24.

Top of Page