2011-03-12 12 views
2

SQLAPI ++를 사용하여 Visual C++ 응용 프로그램에서 Oracle에 연결하고 있습니다. VC++에서 데이터베이스에 쉽게 연결할 수 있습니다. Win32 콘솔 appliation 모드에서만 데이터베이스에 연결할 수 있습니다.Visual C++ Windows Forms 프로젝트의 링커 오류

그러나 Windows Forms 프로젝트에서 동일한 작업을 시도 할 때 다음과 같은 링커 오류가 발생합니다. 데이터베이스에 삽입하기 위해 양식에 입력 된 값이 필요하기 때문에 누군가 도와 줄 수 있습니까?

내 코드는 다음과 같습니다

#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; 
} 

를 내가 얻을 오류가 나는 Win32 콘솔 모드에서 오류를 얻을 해달라고

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]@$$HYMHP$0[email protected]@@@Z) 

sqlapi.obj : error LNK2028: unresolved token (0A000018) "public: void __clrcall SACommand::setCommandText(class SAString const &,enum SACommandType_t)" ([email protected]@@[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) 

이다. 필자는 또한 라이브러리를 추가 종속성에 추가했습니다.

+0

코드가 중요하지 않습니다. 이들은 내부 라이브러리 오류입니다. – NT88

답변

1

저는 C++/CLI와 관련하여 많은 연구를하지 못했습니다. 그러나이 질문에서 대답 한 것과 동일한 문제가 있다고 생각합니다. error linking to oci libraries from vc++.

또한이 스레드의 하단에있는 주석 http://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/44fc45c4-10da-4670-bc5d-2f505ee32fd1은 C++ 창 양식 프로젝트가/clr : pure 모드에 있어야 함을 암시합니다. 콘솔 앱과 다를 수 있습니다. 또한 Window Forms에/clr 모드를 사용하면 얻을 수있는 비주얼 스튜디오의 최신 버전을 사용하고 있는지 궁금합니다.

+0

U 제안에 감사드립니다. U 링크가 도움이되었습니다. 나는 같은 pragma를 사용했지만 clr normal 모드에서 사용했다. b4 나는 clr 순수 모드에서 동일한 작업을 수행 했으므로 오류가 발생했습니다 .clr/pure 모드 대신 clr 모드를 사용하면 관리되지 않는 함수를 사용하는 것 이외의 방법으로 내 양식 프로젝트에 영향을 줍니까? 미리 감사드립니다. – naturmaN

+0

@naturmaN : 이미 다른 질문에서도 설명했습니다. –

+0

@naturmaN 개인적인 경험으로는 알 수 없지만 [MSDN] (http://msdn.microsoft.com/en-us/library/85344whh(v=80) .aspx)은 내가 아는 최고의 참조입니다. 차이점은. 또한 [Expert C++/CLI] (http://www.amazon.com/Expert-Visual-CLI-Programmers-Experts/dp/1590597567/ref=sr_1_1?ie=UTF8&s=books&qid=1300003938&sr)를 둘러 보면서이 책을 발견했습니다. = 8-1). 주위에 C++ Windows Forms 응용 프로그램에 많은 탄탄한 리소스가있는 것 같지 않습니다 ... – jdasilva