我正在使用SQLAPI ++從我的Visual C++應用程序連接到Oracle。 只有當我在Win32控制檯應用程序模式下執行操作時,我纔可以輕鬆地從VC++連接到數據庫。Visual C++ Windows窗體項目中的鏈接器錯誤
但是,當我嘗試在Windows窗體項目中做同樣的事情時,我得到以下鏈接器錯誤。 有人可以幫助我,因爲我需要在窗體中輸入的值插入數據庫。
我的代碼是:
#include <SQLAPI.h>
#include "stdafx.h"
#include "Form1.h"
#include <stdio.h>
using namespace sqlapi;
[STAThreadAttribute]
int main(array<System::String ^> ^args)
{
SAConnection con;
SACommand cmd;
try
{
con.Connect("", "scott", "tiger", SA_Oracle_Client);
cmd.setConnection(&con);
cmd.setCommandText(
"Create table test_tbl(fid integer, fvarchar20 varchar(20), fblob blob)");
cmd.Execute();
cmd.setCommandText(
"Insert into test_tbl(fid, fvarchar20) values (1, 'Some string (1)')");
cmd.Execute();
con.Commit();
}
catch(SAException &x)
{
try
{
con.Rollback();
}
catch(SAException &)
{
}
}
// Enabling Windows XP visual effects before any controls are created
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
Application::Run(gcnew Form1());
return 0;
}
而且我得到的錯誤是
sqlapi.obj : error LNK2028: unresolved token (0A000010) "public: void __clrcall SAConnection::Rollback(void)" ([email protected]@@$$FQAMXXZ) referenced in function [email protected]@[email protected]@@@Z$0
sqlapi.obj : error LNK2028: unresolved token (0A000016) "public: void __clrcall SAConnection::Commit(void)" ([email protected]@@$$FQAMXXZ) referenced in function "int __clrcall main(cli::array<class System::String^>^)" ([email protected]@[email protected]@@@Z)
sqlapi.obj : error LNK2028: unresolved token (0A000018) "public: void __clrcall SACommand::setCommandText(class SAString const &,enum SACommandType_t)" ([email protected]@@$$FQAMXAB[email protected]@[email protected]@@Z) referenced in function "int __clrcall main(cli::array<class System::String^>^)" ([email protected]@[email protected]@@@Z)
sqlapi.obj : error LNK2028: unresolved token (0A000019) "public: void __clrcall SACommand::setConnection(class SAConnection *)" ([email protected]@@[email protected]@@Z) referenced in function "int __clrcall main(cli::array<class System::String^>^)" ([email protected]@[email protected]@@@Z)
sqlapi.obj : error LNK2028: unresolved token (0A00001A) "public: __clrcall SAString::~SAString(void)" ([email protected]@[email protected]) referenced in function "int __clrcall main(cli::array<class System::String^>^)" ([email protected]@[email protected]@@@Z)
sqlapi.obj : error LNK2028: unresolved token (0A00001B) "public: __clrcall SAString::SAString(char const *)" ([email protected]@[email protected]@Z) referenced in function "int __clrcall main(cli::array<class System::String^>^)" ([email protected]@[email protected]@@@Z)
sqlapi.obj : error LNK2028: unresolved token (0A00001C) "public: void __clrcall SAConnection::Connect(class SAString const &,class SAString const &,class SAString const &,enum SAClient_t,void (__cdecl*)(class SAConnection &,enum SAConnectionHandlerType_t))" ([email protected]@@[email protected]@[email protected]@[email protected][email protected]@@[email protected]) referenced in function "int __clrcall main(cli::array<class System::String^>^)" ([email protected]@[email protected]@@@Z)
sqlapi.obj : error LNK2028: unresolved token (0A00001D) "public: virtual __clrcall SACommand::~SACommand(void)" ([email protected]@[email protected]) referenced in function [email protected]@[email protected]@@@Z$0
sqlapi.obj : error LNK2028: unresolved token (0A00001E) "public: __clrcall SACommand::SACommand(void)" ([email protected]@[email protected]) referenced in function "int __clrcall main(cli::array<class System::String^>^)" ([email protected]@[email protected]@@@Z)
sqlapi.obj : error LNK2028: unresolved token (0A00001F) "public: virtual __clrcall SAConnection::~SAConnection(void)" ([email protected]@[email protected]) referenced in function [email protected]@[email protected]@@@Z$0
sqlapi.obj : error LNK2028: unresolved token (0A000020) "public: __clrcall SAConnection::SAConnection(void)" ([email protected]@[email protected]) referenced in function "int __clrcall main(cli::array<class System::String^>^)" ([email protected]@[email protected]@@@Z)
sqlapi.obj : error LNK2019: unresolved external symbol "public: virtual __clrcall SAConnection::~SAConnection(void)" ([email protected]@[email protected]) referenced in function [email protected]@[email protected]@@@Z$0
sqlapi.obj : error LNK2019: unresolved external symbol "public: virtual __clrcall SACommand::~SACommand(void)" ([email protected]@[email protected]) referenced in function [email protected]@[email protected]@@@Z$0
sqlapi.obj : error LNK2019: unresolved external symbol "public: void __clrcall SAConnection::Rollback(void)" ([email protected]@@$$FQAMXXZ) referenced in function [email protected]@[email protected]@@@Z$0
sqlapi.obj : error LNK2019: unresolved external symbol "public: void __clrcall SAConnection::Commit(void)" ([email protected]@@$$FQAMXXZ) referenced in function "int __clrcall main(cli::array<class System::String^>^)" ([email protected]@[email protected]@@@Z)
我不明白在Win32控制檯模式下的任何錯誤。 我甚至還在其他依賴中添加了庫。
您的代碼並不重要 - 這些是一些內部庫錯誤 – NT88 2011-03-12 07:16:11