Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

accesing INFORMIX DBMS via ODBC using C - ERRORS

Status
Not open for further replies.

beon

Programmer
Jan 6, 2003
3
SI
Hello,

I have a problem accesing INFORMIX DBMS via ODBC using C and INTERSOLV 3.1 ODBC DRIVER on Windows 2000 Server.

My source codel looks like:

rc = SQLAllocEnv (&henv);
rc = SQLAllocConnect (henv, &hdbc);
rc = SQLConnect (hdbc,(unsigned char *)dbname, SQL_NTS, (unsigned char *)dbuser, SQL_NTS, (unsigned char *)dbuser_passwd, SQL_NTS);

//**** SELECT ****//
lstrcpy(sql_command,"SELECT area_code, from_dn, to_dn FROM numbering_plan");
rc = SQLExecDirect (hstmt, (unsigned char *)sql_command, SQL_NTS);

The following errors occured:
SQL connect returns 1; SQL_SUCCESS_WITH_INFO
SQLExecDirect returns -2; SQL_INVALID_HANDLE

Where is the catch? What means SQL_INVALID_HANDLE? What am I doing wrong?

Best regards!
 
Hi beon,

You also need to call rc=SQLAllocStatement(hdbc,&hstmt)after allocating the connection handle through SQLAllocConnect to allocate the statement handle. After allocating the statement handle you need to call
SQLExecDirect API. Also it is always better to check the return codes of the API in the program itself and call SQLError API to get more information about the error.

Hope this helps.

-Chintan.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top