kathyayini
Programmer
My code is :
// BCP.cpp : Defines the initialization routines for the DLL.
//
#include "stdafx.h"
//#include "BCP.h"
#define DBNTWIN32
#include <stdio.h>
#include <windows.h>
#include <sqlfront.h>
#include <sqldb.h>
#include <iostream.h> // iostream
#include <stdlib.h> // C run-time
extern "C" int ErrorHandler (PDBPROCESS, INT, INT, INT, LPCSTR, LPCSTR);
extern "C" int MessageHandler (PDBPROCESS, DBINT, INT, INT, LPCSTR, LPCSTR, LPCSTR, DBUSMALLINT);
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define DLLEXPORT _declspec(dllexport)
HINSTANCE g_hInstance;
BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call,LPVOID lpReserved)
{
g_hInstance=(HINSTANCE)hModule;
return TRUE;
}
extern "C" DLLEXPORT BOOL WINAPI BCP(char* lpszProvider, char* lpszDsn, char* lpszCatelog, char* lpszDBUid,char* lpszDBPwd, int Ino_of_threads, char* CSP_Names[],char* CParam[10][10],char* CType[10][10])
{
LOGINREC *login;
DBPROCESS *dbproc;
DBINT rowsread;
// Install error-handler and message-handler.
dberrhandle(ErrorHandler);
dbmsghandle(MessageHandler);
// Open a DBPROCESS.
login = dblogin();
DBSETLUSER(login, "user"
;
DBSETLPWD(login, "my_passwd"
;
DBSETLAPP(login, "example"
;
BCP_SETL(login, TRUE);
dbproc = dbopen(login, "my_server"
;
// Initialize bcp.
//if (bcp_init(dbproc, "pubs..authors", "authors.sav",(BYTE *)NULL, DB_OUT) == FAIL)
// exit(ERREXIT);
// Initialize bcp.
if (bcp_init(dbproc, "comdb..address", "address.add", "addr.err",DB_IN) == FAIL)
exit(ERREXIT);
// Now, execute the bulk copy.
if (bcp_exec(dbproc, &rowsread) == FAIL)
{
printf("Incomplete bulk copy. Only %ld row%s copied.\n",rowsread, (rowsread == 1) ? "": "s"
;
}
return TRUE;
}
extern "C" int ErrorHandler (
PDBPROCESS pDbproc,
INT nSeverity,
INT nDBLibError,
INT nOSError,
LPCSTR pszDBLibError,
LPCSTR pszOSError)
{
if (nDBLibError == SQLEKBCO || nDBLibError == SQLEKBCI)
// handle "1000 rows" message
{
cout << pszDBLibError << endl;
return(INT_CANCEL); // don't quit. continue the process
}
// display DB-Library error information
cout << "DB-Library Error " << nDBLibError << ": " << pszDBLibError << endl;
if ((pDbproc == NULL) || (DBDEAD(pDbproc)))
{
return(INT_EXIT);
}
else
{
if (nOSError != DBNOERR)
{
// this DB-Library error was caused by an operating system
// error, so display OS error information
cout << "Operating System Error " << nOSError << ": " << pszOSError
<< endl;
}
return(INT_CANCEL);
}
}
extern "C" int MessageHandler (
PDBPROCESS pDbproc,
DBINT lMessage,
INT nState,
INT nSeverity,
LPCSTR pszMessage,
LPCSTR pszServer,
LPCSTR pszProcedure,
DBUSMALLINT usLine)
{
// display SQL Server message information
cout << "SQL Server";
if (pszServer != NULL)
{
if (*pszServer != '\0')
{
cout << " '" << pszServer << "'";
}
}
cout << " Message " << lMessage << ": " << pszMessage;
if (usLine != 0)
{
cout << " (Concerning line " << usLine;
if (pszProcedure != NULL)
{
cout << " of stored procedure '" << pszProcedure << "'";
}
cout << "
";
}
cout << endl;
return(0);
}
while compiling i am getting error as follows:
--------------------Configuration: BCP - Win32 Debug--------------------
Compiling...
StdAfx.cpp
Compiling...
BCP.cpp
Linking...
Creating library Debug/BCP.lib and object Debug/BCP.exp
BCP.obj : error LNK2001: unresolved external symbol _bcp_exec
BCP.obj : error LNK2001: unresolved external symbol _bcp_init
BCP.obj : error LNK2001: unresolved external symbol _dbopen
BCP.obj : error LNK2001: unresolved external symbol _bcp_setl
BCP.obj : error LNK2001: unresolved external symbol _dbsetlname
BCP.obj : error LNK2001: unresolved external symbol _dblogin
BCP.obj : error LNK2001: unresolved external symbol _dbmsghandle
BCP.obj : error LNK2001: unresolved external symbol _dberrhandle
BCP.obj : error LNK2001: unresolved external symbol _dbdead
Debug/BCP.dll : fatal error LNK1120: 9 unresolved externals
Error executing link.exe.
BCP.dll - 10 error(s), 0 warning(s)
what could be the reason
waiting for the reply.
// BCP.cpp : Defines the initialization routines for the DLL.
//
#include "stdafx.h"
//#include "BCP.h"
#define DBNTWIN32
#include <stdio.h>
#include <windows.h>
#include <sqlfront.h>
#include <sqldb.h>
#include <iostream.h> // iostream
#include <stdlib.h> // C run-time
extern "C" int ErrorHandler (PDBPROCESS, INT, INT, INT, LPCSTR, LPCSTR);
extern "C" int MessageHandler (PDBPROCESS, DBINT, INT, INT, LPCSTR, LPCSTR, LPCSTR, DBUSMALLINT);
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define DLLEXPORT _declspec(dllexport)
HINSTANCE g_hInstance;
BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call,LPVOID lpReserved)
{
g_hInstance=(HINSTANCE)hModule;
return TRUE;
}
extern "C" DLLEXPORT BOOL WINAPI BCP(char* lpszProvider, char* lpszDsn, char* lpszCatelog, char* lpszDBUid,char* lpszDBPwd, int Ino_of_threads, char* CSP_Names[],char* CParam[10][10],char* CType[10][10])
{
LOGINREC *login;
DBPROCESS *dbproc;
DBINT rowsread;
// Install error-handler and message-handler.
dberrhandle(ErrorHandler);
dbmsghandle(MessageHandler);
// Open a DBPROCESS.
login = dblogin();
DBSETLUSER(login, "user"
DBSETLPWD(login, "my_passwd"
DBSETLAPP(login, "example"
BCP_SETL(login, TRUE);
dbproc = dbopen(login, "my_server"
// Initialize bcp.
//if (bcp_init(dbproc, "pubs..authors", "authors.sav",(BYTE *)NULL, DB_OUT) == FAIL)
// exit(ERREXIT);
// Initialize bcp.
if (bcp_init(dbproc, "comdb..address", "address.add", "addr.err",DB_IN) == FAIL)
exit(ERREXIT);
// Now, execute the bulk copy.
if (bcp_exec(dbproc, &rowsread) == FAIL)
{
printf("Incomplete bulk copy. Only %ld row%s copied.\n",rowsread, (rowsread == 1) ? "": "s"
}
return TRUE;
}
extern "C" int ErrorHandler (
PDBPROCESS pDbproc,
INT nSeverity,
INT nDBLibError,
INT nOSError,
LPCSTR pszDBLibError,
LPCSTR pszOSError)
{
if (nDBLibError == SQLEKBCO || nDBLibError == SQLEKBCI)
// handle "1000 rows" message
{
cout << pszDBLibError << endl;
return(INT_CANCEL); // don't quit. continue the process
}
// display DB-Library error information
cout << "DB-Library Error " << nDBLibError << ": " << pszDBLibError << endl;
if ((pDbproc == NULL) || (DBDEAD(pDbproc)))
{
return(INT_EXIT);
}
else
{
if (nOSError != DBNOERR)
{
// this DB-Library error was caused by an operating system
// error, so display OS error information
cout << "Operating System Error " << nOSError << ": " << pszOSError
<< endl;
}
return(INT_CANCEL);
}
}
extern "C" int MessageHandler (
PDBPROCESS pDbproc,
DBINT lMessage,
INT nState,
INT nSeverity,
LPCSTR pszMessage,
LPCSTR pszServer,
LPCSTR pszProcedure,
DBUSMALLINT usLine)
{
// display SQL Server message information
cout << "SQL Server";
if (pszServer != NULL)
{
if (*pszServer != '\0')
{
cout << " '" << pszServer << "'";
}
}
cout << " Message " << lMessage << ": " << pszMessage;
if (usLine != 0)
{
cout << " (Concerning line " << usLine;
if (pszProcedure != NULL)
{
cout << " of stored procedure '" << pszProcedure << "'";
}
cout << "
}
cout << endl;
return(0);
}
while compiling i am getting error as follows:
--------------------Configuration: BCP - Win32 Debug--------------------
Compiling...
StdAfx.cpp
Compiling...
BCP.cpp
Linking...
Creating library Debug/BCP.lib and object Debug/BCP.exp
BCP.obj : error LNK2001: unresolved external symbol _bcp_exec
BCP.obj : error LNK2001: unresolved external symbol _bcp_init
BCP.obj : error LNK2001: unresolved external symbol _dbopen
BCP.obj : error LNK2001: unresolved external symbol _bcp_setl
BCP.obj : error LNK2001: unresolved external symbol _dbsetlname
BCP.obj : error LNK2001: unresolved external symbol _dblogin
BCP.obj : error LNK2001: unresolved external symbol _dbmsghandle
BCP.obj : error LNK2001: unresolved external symbol _dberrhandle
BCP.obj : error LNK2001: unresolved external symbol _dbdead
Debug/BCP.dll : fatal error LNK1120: 9 unresolved externals
Error executing link.exe.
BCP.dll - 10 error(s), 0 warning(s)
what could be the reason
waiting for the reply.