Click here to Skip to main content
15,879,239 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Hello every body !

1st my E.L not good, i write i think ! :)

now,
I need help, i was try to fix but not work ! it build in flatform C++/CLI

it's have wrong
this is error , details below

error LNK2020: unresolved token (06000001)
error LNK2020: unresolved token (06000002)
error LNK2020: unresolved token (06000002)

details

in stdafx.h
<pre lang="c++">
#pragma once
using namespace System;
using namespace System::Data;
using namespace System::Data::SqlClient;
using namespace System::Collections::Generic;


in SQLservices

<pre lang="c++">#pragma once
#include "stdafx.h"


ref class SQLservices
{


	//variable
private:

	String^ hostserver;	
	String^ dataname;
	static SqlConnection^ sqlcon = gcnew SqlConnection;

	//destroy
protected:
	~SQLservices();

public:

	
	//property
	property String^ HostServer{
		String^ get(){ return hostserver; }
		void	set(String^ value){ hostserver	= value;}
	};

	property String^ DataName{
	        String^ get(){ return dataname;	}
		void	set(String^ value){ dataname= value;}
	}


	//constructor
	SQLservices(void);
	SQLservices(String^ HostServer,String ^DataName);
	

	//method

	Boolean^ checkConnection();
	Boolean^ getStateConnection();
	void closeConnection();
};


in in SQLservices.cpp
C++
#include "stdafx.h"
#include "SQLservices.h"


SQLservices::SQLservices(void){}

SQLservices::SQLservices(String^ mHostServer,String^ mDataName){
	this->HostServer = mHostServer;
	this->DataName= mDataName;
}

SQLservices::~SQLservices(){}

System::Boolean^ SQLservices::checkConnection(){
	sqlcon->ConnectionString = "Data source = " + this->hostserver + ";Initial Catalog = " + this->dataname + ";Integrated Security=True; Pooling = false; MultipleActiveResultSets=True; TrustServerCertificate=False; User Instance=False"; 
	try{
		sqlcon->Open();
		return true;
	}
	catch (...){
		return false;
	}
}

System::Boolean^ SQLservices::getStateConnection(){ return (sqlcon->State == ConnectionState::Open) ? true :false ; }

System::Void SQLservices::closeConnection(){
	try{
		sqlcon->Close();
	}
	catch(...){/*nothing to do */}
}



in class Form1.h i using class SQLservices

C++
#include "SQLservicer.h"

//declare class SQLservices
SQLservicer^ SQLTools;

//using SQLTools in btnTestConnection  in event Click
String^ host = gcnew String(tbxHostServer->Text);
String^ data = gcnew String(tbxDataName->Text);

SQLTools = gcnew SQLservicer(host,data);

if(SQLTools->CheckConnectionSQL()) {...}

and now here is error
<pre lang="c++">Error	1	error LNK2020: unresolved token (06000001) BaiTapNhom_ADO.SQLservicer::.ctor	D:\Studing\Solution\VisualCPlusplus\Work_ADO\Work_ADO\Work_ADO.obj	Work_ADO
Error	2	error LNK2020: unresolved token (06000002) BaiTapNhom_ADO.SQLservicer::CheckConnectionSQL	D:\Studing\Solution\VisualCPlusplus\Work_ADO\Work_ADO\Work_ADO.obj	Work_ADO
Error	3	error LNK2020: unresolved token (06000003) BaiTapNhom_ADO.SQLservicer::~SQLservicer	D:\Studing\Solution\VisualCPlusplus\Work_ADO\Work_ADO\Work_ADO.obj	Work_ADO
Error	4	error LNK1120: 3 unresolved externals	D:\Studing\Solution\VisualCPlusplus\Work_ADO\Debug\Work_ADO.exe	Work_ADO
Posted
Comments
CHill60 23-Sep-13 15:31pm    
You need to include the SQLServicer library in your link options.
NV Quyền 23-Sep-13 15:33pm    
please , Can you show me more clearly !
i include the SQLservicer in where ?
CHill60 23-Sep-13 15:41pm    
It's been a while (a few years) since I did any C++ and I can't remember the exact place to put the libraries ... have a look here and see if it helps http://www.oracle.com/technetwork/articles/servers-storage-dev/linkinglibraries5-423431.html[^]
NV Quyền 23-Sep-13 15:44pm    
tsk You alot

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900