3

How to create an embedded mysql db with C#?

1
  • More info is needed on the question. Commented May 27, 2015 at 6:23

4 Answers 4

4
  1. Define "embedded"

  2. If you're trying to use MySQL without installing MySQL, you're out of luck. SQLite and SQL Server Compact Edition (see Matthew's link) are about your only options for using a database without installing a server.

Sign up to request clarification or add additional context in comments.

4 Comments

Can I create mysql db with C# in the custom directory?
I'm not sure what you're asking. What is "custom directory?" And I still don't know what you mean by "embedded."
"Embedded" means without installing MySQL. I've understood your answer. Path to the mysql db should be customizable(different at the different clients). I need to set it in C# code. Is it possible?
If you want to use a MySQL database from C#, you have to install MySQL, which typically requires admin privileges. If you want to "embed" the database, you'll have to use SQL Server CE or SQLite.
2

"The embedded server library is based on the client/server version of MySQL, which is written in C/C++. Consequently, the embedded server also is written in C/C++. There is no embedded server available in other languages"

http://dev.mysql.com/doc/refman/5.0/en/libmysqld.html

1 Comment

c/c++ can be "easily" wrapped to expose the library to .net. did anybody do this?
1

You should check out SQL CE 4.0.

http://www.microsoft.com/sqlserver/en/us/editions/compact.aspx

Comments

1

I created an application that embedded SQLite and alternately SQL Server CE. Of the two I found that SQLite was much easier to implement and required no standalone installation to work properly.

I found SQL Server CE to be extremely limited in basic functions for working with data and did not allow me to implement what was missing as User Defined Function in C#. On the other hand SQLite provided a richer set of functions out of the box. It also allowed me to implement any UDFs I wanted in C#. The result was that it was far easier to implement my application.

The one drawback I had using SQLite was in the mapping of data types imported from SQL Server. SQLite they always returned long values as output when the input was only integer and in some cases the return values from the ADO provider were long values when the actual values were float or doubles. It did not always play well when numeric types were first null or integer and later valid doubles and rounded when it should not have. I was forced to implement explicit double expressions when querying the data to prevent rounding.

While both allowed me to store data and to execute SQL I found SQL Server CE to be too limited from a functional perspective and ultimately I did not use it in the final result.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.