Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

Posted

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?

Posted

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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...