Issues when Integrating SQL API++ with Visual Studio 2008, when trying to make Database Connection from C++ Program to SQL Server 2005

  • Thread starter Thread starter Aravind Krishnan
  • Start date Start date
A

Aravind Krishnan

Guest


Getting the following Error messages, when i build this code against SQL Server2005 using Windows Authentication.



1>------ Rebuild All started: Project: DALSASQLTest, Configuration: Debug Win32 ------
1>Deleting intermediate and output files for project 'DALSASQLTest', configuration 'Debug|Win32'
1>Compiling...
1>SQLTest.cpp
1>Linking...
1>SQLTest.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall SAConnection::~SAConnection(void)" (??1SAConnection@@UAE@XZ) referenced in function __catch$_main$0
1>SQLTest.obj : error LNK2019: unresolved external symbol "public: __thiscall SAString::operator char const *(void)const " (??BSAString@@QBEPBDXZ) referenced in function __catch$_main$0
1>SQLTest.obj : error LNK2019: unresolved external symbol "public: class SAString __thiscall SAException::ErrText(void)const " (?ErrText@SAException@@QBE?AVSAString@@XZ) referenced in function __catch$_main$0
1>SQLTest.obj : error LNK2019: unresolved external symbol "public: void __thiscall SAConnection::Rollback(void)" (?Rollback@SAConnection@@QAEXXZ) referenced in function __catch$_main$0
1>SQLTest.obj : error LNK2019: unresolved external symbol "public: void __thiscall SAConnection::Disconnect(void)" (?Disconnect@SAConnection@@QAEXXZ) referenced in function _main
1>SQLTest.obj : error LNK2019: unresolved external symbol "public: __thiscall SAString::~SAString(void)" (??1SAString@@QAE@XZ) referenced in function _main
1>SQLTest.obj : error LNK2019: unresolved external symbol "public: void __thiscall SAConnection::Connect(class SAString const &,class SAString const &,class SAString const &,enum SAClient_t,void (__cdecl*)(class SAConnection &,enum SAConnectionHandlerType_t))" (?Connect@SAConnection@@QAEXABVSAString@@00W4SAClient_t@@P6AXAAV1@W4SAConnectionHandlerType_t@@@Z@Z) referenced in function _main
1>SQLTest.obj : error LNK2019: unresolved external symbol "public: __thiscall SAString::SAString(char const *)" (??0SAString@@QAE@PBD@Z) referenced in function _main
1>SQLTest.obj : error LNK2019: unresolved external symbol "public: __thiscall SAConnection::SAConnection(void)" (??0SAConnection@@QAE@XZ) referenced in function _main
1>MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
1>C:\Users\aravind\Documents\Visual Studio 2008\Projects\DALSASQLTest\Debug\DALSASQLTest.exe : fatal error LNK1120: 10 unresolved externals
1>Build log was saved at "file://c:\Users\aravind\Documents\Visual Studio 2008\Projects\DALSASQLTest\DALSASQLTest\Debug\BuildLog.htm"
1>DALSASQLTest - 11 error(s), 0 warning(s)
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========



<br/>


Code is below:


#include <stdio.h>


#include <SQLAPI.h> // main SQLAPI++ header

int main(int argc, char* argv[])
{
SAConnection con; // create connection object

try
{
// connect to database
// in this example it is SQL Server,
// but can also be Sybase, Informix, DB2

con.Connect(
"Patient", // database name
"", // user name
"", // password
SA_SQLServer_Client);

printf("We are connected!\n");

// Disconnect is optional
// autodisconnect will ocur in destructor if needed
con.Disconnect();

printf("We are disconnected!\n");
}
catch(SAException &x)
{
// SAConnection::Rollback()
// can also throw an exception
// (if a network error for example),
// we will be ready
try
{
// on error rollback changes
con.Rollback();
}
catch(SAException &)
{
}
// print error message
printf("%s\n", (const char*)x.ErrText());
}

return 0;
}


Continue reading...
 
Back
Top