-
October 3rd, 2003, 05:24 AM
#1
Linking Errors in VC++
I have a database application thru SQL MFC that uses vectors and it is done in VC++ (its a Win32 Application and an empty project having only one source CPP File called MyCPPFile.CPP)
The headers are as follows:
# include <string.h>
# include <ctype.h>
# include <afx.h>
# include <afxdb.h>
# include <sql.h>
# include <sqlext.h>
# include <stdlib.h>
# include <conio.h>
# include <vector>
# include <iostream>
using namespace std;
some portion of main() is as follows:
int main(void)
{
HENV hEnv = NULL; // Env Handle from SQLAllocEnv()
HDBC hDBC = NULL; // Connection handle
HSTMT hStmt = NULL; // Statement handle
UCHAR* szUID = NULL; // User ID buffer
UCHAR* szPasswd = NULL;// Password buffer
UCHAR* szOutConn = NULL;
UCHAR szAddr_Org[200];// price buffer
SDWORD cbAddr_Org; // price buffer bytes recieved
SQLSMALLINT* cbOutConn = NULL;
SQLSMALLINT cbConnOutMax;
UCHAR szSqlStr1[]
= "Select address From MyTable";// SQL string
RETCODE retcode; // Return code
SQLAllocEnv (&hEnv);
SQLAllocConnect (hEnv, &hDBC);
retcode = SQLDriverConnect(hDBC, NULL, (SQLTCHAR*) "DRIVER={Microsoft Access Driver (*.mdb);}DBQ=D:\\MyFolder\\MyDatabase.mdb", SQL_NTS, (SQLTCHAR*) szOutConn, cbConnOutMax, cbOutConn, SQL_DRIVER_COMPLETE);
if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO)
{
retcode = SQLAllocStmt (hDBC, &hStmt);
retcode = SQLPrepare (hStmt, szSqlStr1, sizeof (szSqlStr1));
retcode = SQLExecute (hStmt);
SQLBindCol (hStmt, 1, SQL_C_CHAR, szAddr_Org, sizeof(szAddr_Org), &cbAddr_Org);
retcode = SQLFetch (hStmt);
/* Some processing statements...
..........;
..........;
..........;
*/
SQLFreeStmt (hStmt, SQL_DROP);
SQLDisconnect (hDBC);
}
SQLFreeConnect (hDBC);
SQLFreeEnv (hEnv);
return 1;
}
ERROR ON LINKING THAT I GET:
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __endthreadex
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __beginthreadex
when I had SQLConnect() function , I made a forced type EXE. EXE worked properly but it isn't working when i use SQLDriverConnect() in main().
SQLDriverConnect() uses NULL parameter for HWND (Windows handle) hwnd argument i think due to which I get Execution error in Module WinMain.CPP saying that
"Access Violation:Unhandled exception at 0x0000F " or something like that
Debugger opens a Module WinMain.CPP where following statement has DEBUG POINTER ===>
===> if (!pThread->InitInstance())
{
if (pThread->m_pMainWnd != NULL)
{
TRACE0("Warning: Destroying non-NULL m_pMainWnd\n");
pThread->m_pMainWnd->DestroyWindow();
}
nReturnCode = pThread->ExitInstance();
goto InitFailure;
}
........
Why is this error? Has I included too many header files that cause conflict in declarations of some modules? If yes then which one should I exclude? Plz help
Thanks
Vinit Sankhe.
V.V.Sankhe
-
October 3rd, 2003, 06:20 AM
#2
In your project settings, since your using MFC, under general, select either static or shared for MFC
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|