A "step by step" connection with VSc++.net?
Posted by:
Gefi Finne
Date: November 10, 2004 07:01PM
Hi I dont know much about this but now i have a school project and i am really in need of some help!
I use:
VB.Net, C++, MFC Application, Dialog Based
MySql connector-net 1.1
Is there any easy "step by step" instruction on how to get connected to MySql?
I have tryed alot, but the errors never seems to end...
1. Put the MySql.Data.dll(from MySql connector) file in the main project-folder and added it to the "references" in "Solution Explorer".
2. Put the "Use Managed Extensions"(in Configuration Properties) to "Yes".
3. Took away the #define new DEBUG_NEW(in both the *.cpp and the *Dlg.cpp file).
#ifdef _DEBUG
//#define new DEBUG_NEW
#endif
4. Added the header(in both the *.cpp and the *Dlg.cpp file).
#using <mscorlib.dll>
#using <System.Dll>
#using <System.Data.Dll>
#using <System.Xml.Dll>
using namespace System;
using namespace System::Data;
using namespace System::Xml;
using namespace System::Collections;
using namespace MySql::Data::MySqlClient;
5. Found System::Data::SqlClient code and changed all "Sql" into "MySql", and changed "string" into "char*".
//START
void Csem17Dlg::OnBnClickedButton1()//Yes, this is the 17th time i start over again ;)
{
// TODO: Add your control notification handler code here
MySqlConnection* objConn;
char* sConnectionString;
sConnectionString = "Password=mysql;User ID=root;Initial Catalog=Table;Data Source=localhost";
objConn = new MySqlConnection(sConnectionString);
//This sentence is the probleme.
//I get send to swich nSig, case AfxSigCmd_v and get the data
//Name: pTarget, Type: CcmdTarget* in the debug window
objConn->Open();
MySqlDataAdapter* daColumn1 = new MySqlDataAdapter("Select * From Column1 ", objConn);
DataSet* dsTable = new DataSet("Table");
daColumn1->FillSchema(dsTable,SchemaType::Source, "Column1");
daColumn1->Fill(dsTable,"Column1");
//daColumn1->MissingSchemaAction = MissingSchemaAction::AddWithKey;
//daColumn1->Fill(dsTable,"Column1");
DataTable* tblColumn1 = dsTable->Tables->Item["Column1"];
IEnumerator* iEnum = tblColumn1->Rows->GetEnumerator();
while(iEnum->MoveNext())
{
Console::WriteLine("{0} {1}",dynamic_cast<String*>(dynamic_cast<DataRow *>(iEnum->Current)->get_Item("au_fname")),
dynamic_cast<String*>(dynamic_cast<DataRow *>(iEnum->Current)->get_Item("au_lname")));
}
UpdateData(FALSE);
}
//END
Does anyone have any idea what i missed out? or where i can find some instructions so i can figure it out myself?
thanks
Subject
Written By
Posted
A "step by step" connection with VSc++.net?
November 10, 2004 07:01PM
November 11, 2004 04:29AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.