library libmysql.dll

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for MySQL
Post Reply
theud

library libmysql.dll

Post by theud » Mon 22 Nov 2004 17:19

hi. I try to build a basic program to connect to my database. I put this line in the program : #using "c:\Program Files\CoreLab\MySQLDirect.Net\CoreLab.MySQL.dll", but then i suppose you need to had a mysql library, otherwise you can't use Mysql command. i think you need the libmySQL.dll library. So my precise (and somewhat trivial ?) question is : how to "include" this library with VC++.net ? I tried several way, but it failed... thanks to answer me.

theud

Post by theud » Tue 23 Nov 2004 10:27

More precisely, I write this line #using , I copy this file in WINNT\SYSTEM32. But then i have the error : failure of #using sur 'c:\program files\easyphp1-7\php\libmysql.dll' (translated from french)...

Oleg
Devart Team
Posts: 264
Joined: Thu 28 Oct 2004 13:56

Post by Oleg » Thu 25 Nov 2004 09:19

You needn't libmysql.dll file at all if you use MySQLDirect .NET 2.70.
MySQLDirect .NET includes set of demo projects for C++ .NET.

theud

Post by theud » Thu 25 Nov 2004 11:26

when using Db tools, i can connect to my data base, and make changes on it. But i can't do that with such simple program as this :

#include "stdafx.h"

#using

#using
#using
#using
#using
//c:\Program Files\CoreLab\MySQLDirect.Net\

using namespace System::Windows::Forms;
using namespace System;
using namespace System::Data;
using namespace System::Data::SqlClient;

// This is the entry point for this application
#ifdef _UNICODE
int wmain(void)
#else
int main(void)
#endif
{
// Create a SqlConnection object


// Set the connection string
MySqlConnection *cnPubs = new MySqlConnection("User=root; Host=localhost; Port=3306; Database=td";);

try
{
// Try to open the connection
cnPubs->Open();
Console::WriteLine(S"Connected to database successfully!");






}
catch (MySqlException * Xcp)
{
Console::Write(S"Error occurred: ");
Console::WriteLine(Xcp->Message);
}

// Close the connection
if (cnPubs->State != ConnectionState::Closed)
{
cnPubs->Close();
}
Console::WriteLine(S"The database connection is now closed");


because the compilator don't understand MySqlConnection and so on...
I could not find anywhere in the samples an example of such a simple application in C++.Net... would it be possible to send be a complete simple example so that i could at least connect to my database ?

Oleg
Devart Team
Posts: 264
Joined: Thu 28 Oct 2004 13:56

Re: library libmysql.dll

Post by Oleg » Thu 25 Nov 2004 15:50

You forgot to enable CoreLab::MySql namespace.
Create Console Application (С++ .NET) project and try to add there the following code sample:

Code: Select all

#include "stdafx.h"
#using 
#using 
using namespace System;
using namespace CoreLab::MySql;

 int _tmain()
{
 MySqlConnection * connection = new
 MySqlConnection("User=root;Host=localhost;Port=3306;Database=test");

 connection->Open();
 Console::WriteLine( __box(connection->State)->ToString() );
 connection->Close();

 return 0;
}

theud

pb of connection with mysql

Post by theud » Fri 26 Nov 2004 14:39

ok, i think this is better with this line... :D But i have another problem : i use easyPHP, with Apache server. I change the port of this server from 80 to 8080. but when i try to connect to my data base using DbExplorer, it fails...whereas i could do that in the past. so there is still something wrong with the parameters....

theud

Post by theud » Fri 26 Nov 2004 16:12

well, maybe i made a mistake, now i'm ok with the coonection with DbExplorer. But, with your (somewhat changed) program :

#include "stdafx.h"
#using
#using
#using
#using
using namespace System;
using namespace System::Data;
using namespace CoreLab::MySql;

int main()
{
MySqlConnection * cntd= new MySqlConnection("User=root;Host=localhost;Port=3306;Database=td");

cntd->Open();
Console::WriteLine( __box(cntd->State)->ToString() );
cntd->Close();

return 0;
}

i have this error :

"C:\WINNT\SYSTEM32\NTDLL.DLL, Impossible to find or open a needed file DBG" , "C:\WINNT\SYSTEM32\SHELL32.DLL, Impossible to find or open a needed file DBG" and a lot of other similar error...

Oleg
Devart Team
Posts: 264
Joined: Thu 28 Oct 2004 13:56

Post by Oleg » Tue 30 Nov 2004 08:06

Try instead of using this code:

Code: Select all

#using 
#using 
#using 
#using 
to add in the project references using VisualStudio interface.

Post Reply