Is it possible to connect to a Mysql database without Mysql.Data.dll?

Asked

Viewed 559 times

0

Whenever I will use a Mysql database in a console or windows Forms application, you need to have the dll MySql.Data.dll inside the application folder.

With that, I wonder, if you have any way to use Mysql without a dll. I thought to try using the System.Data.SqlClient, but I don’t know if it’s possible.

  • 1

    There’s always, I can’t tell the size of juggling to get.

  • @Bigown knows at least where I should start?

  • The problem is just this, it has many forms spread.

1 answer

1

The System.Data.SqlClient(reference here) is exclusive to SQL Server(as in this LINQ response). Without a third-party DLL it is almost impossible to connect.

According to my searches there are other ways to connect MYSQL to c# and is not exclusive to MySql.Data.dll. On that website found some connector options for . NET:

I believe that the MySQLDriverCS is the most used, the rest should no longer be used in the market (difficult to find references). Follow example using the MySQLDriverCS found at that link.

    using MySQLDriverCS;
    using System.Data;
    MySQLConnection myConn;
    MySQLDataReader MyReader = null;
    try
    {
      myConn = new MySQLConnection(new MySQLConnectionString("123.456.789.100",
                                                    "mydatabase",
                                                    "user",
                                                    "pass").AsString);
      myConn.Open();
      string sql = "SELECT * FROM Table";
      MySQLCommand cmd = new MySQLCommand(sql, myConn);  
      MyReader = cmd.ExecuteReaderEx();
      while (MyReader.Read())
      {
        Console.WriteLine( MyReader["Product_Name"].ToString() );
      }
      MyReader.Close();       
    }
    catch(Exception ee)
    {
      Console.WriteLine( ee.ToString() );
    }
    finally
    {
       if (MyReader != null && !MyReader.IsClosed)
       {
          MyReader.Close();
       }
       if (myConn != null && myConn.State == ConnectionState.Open)
       {
          myConn.Close();
       }
    }

From what I understand is VERY MUCH similar to the MySql.Data.dll.

  • From what I’ve seen all require some dll or installation, none leaves the source code or something like that.

  • @Francisco kkk is that before you edit, you said "with THIS dll"

  • @Francisco without DLL not possible.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.