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
#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(...){}
}
in class Form1.h i using class SQLservices
#include "SQLservicer.h"
SQLservicer^ SQLTools;
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