Help with embedding MySql into C# .net windows App

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for MySQL
jacobds

Help with embedding MySql into C# .net windows App

Post by jacobds » Thu 11 Nov 2004 21:43

I am fairly new to c# as most of my background is in Java. But I have the task of embedding mySql 4.1.7 into a c# windows app. It seems that all of the information on the web assumes a bit of higher knowledge than I have about embedding. If you find the time, could you explain a little bit about specifically how to embed mySql into a c# program. Also I am aware that there needs to be some sort of c++ go between. I would also need some help getting an embedded mySql. I think the file is something like libmysqld. Any help would be nice.

Thanks

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

Re: Help with embedding MySql into C# .net windows App

Post by Oleg » Fri 12 Nov 2004 14:25

You can find a detailed instruction how to use MySQL Embedded Server in MySQLDirect .NET documentation.

jacobds

Post by jacobds » Fri 12 Nov 2004 16:04

Thanks, this seems very helpful. However I am having trouble getting the libmysqld compiled as I don't have 6.0, only .NET and I am unable to follow the instructions for the changes to be made in .NET. Are there insturctions for how to compile the dll in .NET, or is there a way that you could simply send me the recompiled libmysqld.dll?

Thanks,

Jacob

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

Post by Oleg » Mon 15 Nov 2004 15:33

Please contact us at mysqlnet support email and we'll send you libmysqld.dll that MySQLDirect .NET works with.

jacobds

Post by jacobds » Tue 16 Nov 2004 20:26

I recieved the dll file but I am still having problems getting into my project. I am unable to add it as a reference because it does not realize that it is a valid COM or dll component. When I create a mysql connection object, and set the embedded property to true, it says that it is unable to load the libmysqld.dll. Are there any core lad examples of how to use embedded servers? Or any Idea what I am missing?

Thanks

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

Post by Oleg » Wed 17 Nov 2004 13:33

You shouldn't set reference to libmysqld.dll as it is unmanaged dll.
Try to place libmysqld.dll into WINNT\SYSTEM32 or to the folder with your application.
To use MySQL Embedded server you should configure it and set MySqlConnection.Embedded = true.
You can read about adjusting MySQL Embedded server in 'Configuration and Distribution' paragraph of 'Using
embedded server' article.

jacobds

Post by jacobds » Wed 17 Nov 2004 14:13

I placed the libmysqld.dll in the system32 folder, and when I set embedded = true on the sql connection, it seems to find it as it doesn't give me an error, but the program crashes. I have tried it several times in several different projects. Every time the program just crashes, no error message, or "not responding", simply stops running. if I take the .dll out of the system32 folder, the program works, but again the same error of not finding the dll

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

Post by Oleg » Wed 17 Nov 2004 15:25

Add the next section to your my.ini file.
If you don't have my.ini create it in WINNT folder:

[embedded]
basedir=C:/mysql/
datadir=C:/mysqlembedded/data/

jacobds

Post by jacobds » Thu 18 Nov 2004 18:26

I guess I need a bit more explanation. It seems that putting in an ini file and refrencing the c:/MySql folder is talking about an install. I thought that the point of an embedded server is that we could only ship the dll file with the install and simply reference that. The hope is to not have to install mysql at all.

thanks again for all your help,

Jacob

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

Post by Oleg » Mon 22 Nov 2004 12:00

You needn't install MySQL in this configuration.
You only need contents of c:\mysql\share folder from MySQL.

Shoppa

Post by Shoppa » Fri 26 Nov 2004 11:05

Hi,

I seem to have the same problem as jacobds. The program just stop when it try to open the connection to the embedded server.

Did you get it to work jacobds? If you did, I am very curious in how. Any help would be apreciated.

[email protected]

jacobds

Post by jacobds » Mon 29 Nov 2004 13:17

Well, actually I gave up using MySQL. I decided to go with FireBird, and was able to embed that database with no problem. The only problem there is that the Data Provider that FireBird has is really still being developed and is not nearly as nice to use as the corelab's MySQL Dataadapter. What would really be nice is if Core Labs would whip out a nice Data Adapter for FireBird. :)



Sorry I couldn't be more help.

-Jacob

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

Post by Oleg » Tue 30 Nov 2004 08:53

jacobds couldn't use MySQL embedded server by the next reasons:
  • he tried to use tables from MySQL 4.1.7, but libmysqld that we sent has version 4.0. Thus tables must be created for MySQL 4.0
  • MySQL server service was started
  • after installing my.ini file VisualStudio IDE wasn't restarted.
Possible, there are another reasons. Most of the problems are described in "Using embedded server" article in the documentation for MySQLDirect .NET, some problems are described in MySQL documentation.

CLIPER
Posts: 2
Joined: Sat 14 Jun 2008 11:27
Location: Philippines
Contact:

Post by CLIPER » Sat 14 Jun 2008 11:31

Hi, is there any follow-up examples of this post?
Perhaps there should be an example code for invoking methods from the libmysqld.dll itself? or no need?


Cheers,

CLIPER

Alexey.mdr
Posts: 729
Joined: Thu 13 Dec 2007 10:24

Post by Alexey.mdr » Tue 17 Jun 2008 14:02

Hello,

Well, there is no need for the dedicated MySQL embedded server samples.
You can simply configure MySqlConnection to use the embedded server and run all the currently available samples.

Regards,
Alexey.

Post Reply