Search code examples
c#mysqllocal-databasecompact-database

How to Create MySQL Compact Database?


I want to use MySQL like SQL Compact Edition! In other words, I want to create a local database (compact database file) by MySQL csharp drivers in from Connector/Net .

In my project we need first to install MySql.Data.dll in the GAC and my Data Source is a file path like: D:\MyDatabase\database.myd

Now my codes must be like this:

 using System;
 using System.Data;
 using MySql.Data.MySqlClient;

 public class Test
 {
    public static void Main(string[] args)
    {
       string strConnection = "CREATE DATABASE TestDatabase;";

       MySqlConnection conDatabase = new MySqlConnection("Data Source=D:\MyDatabase\database.myd;Persist Security Info=yes");

       MySqlCommand cmdDatabase = new MySqlCommand(strConnection, conDatabase);

       conDatabase.Open();
       cmdDatabase.ExecuteNonQuery();
       conDatabase.Close();
    }
 }

Can I do it ?


Solution

  • I did research on the internet and realized that MySQL can not be compact and I use Sqlite instead of MySQL.

    Some compact databases:

    • Firebird
    • SQL Server CE
    • Sqlite