Some problem connectting data source with ODBC API 
Author Message
 Some problem connectting data source with ODBC API

In recentness, I am trying to connect a data source with API. but VC always
prompt Linking error to me. following is my key code:

////////////////////////////////////////////////////////////////////////////
#include "sql.h"
#include "sqlext.h"
#include "sqltypes.h"

//......

void CSomeClass::ODBCTest( )
{
 BOOL Success = FALSE;

 SQLHENV henv = NULL;
 SQLHDBC hdbc = NULL;
 BOOL bConnected = FALSE;
 SQLHSTMT hstmt = NULL;

 SQLRETURN rtcode;

 SWORD sMsgNum = 0;
 char szState[7] = "";
 SDWORD pfNative = 0;

    rtcode = ::SQLAllocHandle(SQL_HANDLE_ENV,
  SQL_NULL_HANDLE, &henv);
 if (rtcode != SQL_SUCCESS)
  TRACE("Cannot allcote env handle\n");

 rtcode = ::SQLSetEnvAttr(henv, SQL_ATTR_ODBC_VERSION,
  (void*)SQL_OV_ODBC3, SQL_IS_INTEGER);
 if (rtcode != SQL_SUCCESS)
  TRACE("Cannot set ODBC version\n");

 rtcode = ::SQLAllocHandle(SQL_HANDLE_DBC, henv, &hstmt);
 if (rtcode != SQL_SUCCESS)
  TRACE("Cannot allocate the connect handle/n");

    rtcode = ::SQLConnect(hdbc,
  (SQLCHAR*)"northwind", SQL_NTS,
  (SQLCHAR*)"", SQL_NTS,
  (SQLCHAR*)"", SQL_NTS);
 if (rtcode != SQL_SUCCESS)
  MessageBox(
  "Connectting datat source is faile.\n");
 else
  MessageBox(
  "Connectting data source is successful.\n");

 ::SQLDisconnect(hdbc);
 ::SQLFreeHandle(SQL_HANDLE_DBC, hdbc);
 hdbc = NULL;
 ::SQLFreeHandle(SQL_HANDLE_ENV, henv);
 henv = NULL;

Quote:
}

////////////////////////

this function is no problem in compilling, while to linking, some linking
error appear to me:

////////////////
Linking...





Debug/Myodbc.exe : fatal error LNK1120: 5 unresolved externals
Error executing link.exe.
//////////////////////////////////////////////////////////////////

if I mark a stop point in sentence " SQLRETURN rtcode", I got the warning:
"unreferenced local variable".
I have included three necessary head file in my project, "sql.h",
"sqlext.h",
"sqltypes.h". In my idea, SQLRETURN should be declare in this three head
files. Am I right?

gurus,please help me! thanks in advance.



Sun, 09 Mar 2003 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Some problem connecting data source with ODBC API

2. Some problem connecting data source with ODBC API

3. Some problem connecting data source with ODBC API

4. Some problem connecting data source with ODBC API

5. Data Source: Programmatically Configuring an ODBC Data Source - HELP PLEASE

6. Data Source: Programmatically Configuring an ODBC Data Source - HELP PLEASE

7. Data Source: Programmatically Configuring an ODBC Data Source - HELP PLEASE

8. Problems with CRecordSet with Text ODBC data source

9. DAO: problems attaching external tables (ODBC data sources)

10. problem in using Recordset to open ORACLE database via ODBC system data source

11. Problem using a DLL to connect to ODBC Data Source

12. ODBC API, SQL_C_DATE - how to retrieve field data?

 

 
Powered by phpBB® Forum Software