grip003 Posted September 23, 2005 Posted September 23, 2005 I am writing my own GUI front end for MySQL using C# and the ByteFX libraries. When the user wants to open a database, it asks for the server, port #, database, user name, and password to connect to MySQL. I have a test function that looks like the following: public bool testConnection(string server, string port, string d_base, string user, string password) { string con_str = "Data Source=" + server + ";Port=" + port + ";Database=" + d_base + ";User ID=" + user + ";Password='" + password + "'"; MySqlConnection mysql_conn = new MySqlConnection(con_str); try { mysql_conn.Open(); mysql_conn.Close(); return true; } catch (Exception) { mysql_conn.Dispose(); return false; } } If I put the correct informtion in the FIRST time, this function returns true. However, if I put in some incorrect information the first time (which returns false) but then correct the information and try it again, it returns false. Actually it returns false everytime after the initial wrong entry. The exception I get is Access denied for user ...@... Is this a MySQL issue or a programming issue? I can't seem to get this to work. Quote
grip003 Posted September 23, 2005 Author Posted September 23, 2005 Small Addition I just tried something else and it really confused me. I tried entering the correct information, which worked. Then I went back and tried entering wrong information, and that returned true!! So, whatever I enter the first time seems to stay in the connection somehow. Any ideas? Quote
FZelle Posted September 23, 2005 Posted September 23, 2005 Seems to be an issue with ConnectionPooling. Try to dispose() the connection everytime. Quote
penfold69 Posted September 26, 2005 Posted September 26, 2005 Are you using hte ByteFX 0.76 library? If so, I'd recommend that you upgrade to the MySql Connector.Net 1.0.5 found on the MySql web site. Its essentially that same codebase, but 1.0.5 has been greatly extended since Reggie (the original author of the ByteFX stuff) became employed by MySql. B. Quote
grip003 Posted September 27, 2005 Author Posted September 27, 2005 Thanks: I am goind to try switching to MySQL Connector.NET 1.0.5. I hope that it is used in basically the same way as the ByteFX connector. Quote
grip003 Posted September 27, 2005 Author Posted September 27, 2005 WOW!! All I did was remove my reference to ByteFX, add a reference to the MySQL Connector.NET and everything works perfectly! Thanks penfold69! Quote
penfold69 Posted September 28, 2005 Posted September 28, 2005 No problem, 1.0.6 was released yesterday tho' :D B. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.