Note that there are some explanatory texts on larger screens.

plurals
  1. POConnect C# to Mysql database
    primarykey
    data
    text
    <p>I want to connect to mysql server from C#. I found some code on the net but somewhere there is something wrong because i get </p> <blockquote> <p>A first chance exception of type 'System.ArgumentException' occurred in System.Data.dll</p> </blockquote> <p>error.</p> <pre><code>private void Initialise() { server = "dns to server"; database = "db_name"; uid = "root"; password = "password"; string connectionString; connectionString = "SERVER=" + server + ";" + "DATABASE=" + database + ";" + "UID=" + uid + ";" + "PASSWORD=" + password + ";"; OR connectionString = "Server=xxx.no-ip.org;Database=rdb;"+ "Uid=root;Pwd=wHt2%Zt;"; connection = new MySqlConnection(connectionString); if (this.OpenConnection() == true) Console.Out.Write("SUCCESS"); else Console.Out.Write("ERROR"); } private bool OpenConnection() { try { connection.Open(); return true; } catch (MySqlException ex){ switch (ex.Number) { case 0: MessageBox.Show("Cannot connect to server. Contact administrator"); break; case 1045: MessageBox.Show("Invalid username/password, please try again"); break; } return false; } } </code></pre> <p>I don't get any message on the console. I added <code>Mysql.Data</code> as a reference to my project and i used <code>using MySql.Data.MySqlClient;</code></p> <p>I also tried connectig through gui but with no luck. Ideas ?</p> <p>Edit 1 : with either connection string my program is still not working.</p> <p>Edit 2 : OpenConnection method added.</p> <p>Edit 3 : <a href="http://pastebin.com/WE2BZrav" rel="nofollow">This is the error i get !</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload