0

For the past month I've been getting data with a C# program in tandem with a company's API. Just yesterday all the sudden it would no longer work, even though I haven't changed the code at all. Here's the code:

    public string GetMatchCode()
        {
            //this could be loaded from config file or other source
            string connectString = "Server=123.123.1.23;Database=blah_users;Uid=blah_data;Pwd=blahblah;";
            string sql = "SELECT MAX(match_id) FROM `data_blah`";
            using (var connect = new MySqlConnection(connectString))
            using (var command = new MySqlCommand(sql, connect))
            {
                connect.Open();
                return command.ExecuteScalar().ToString();
            }
        }

And I get this error:

An unhandled exception of type 'MySql.Data.MySqlClient.MySqlException' occurred in MySql.Data.dll

Additional information: Access denied for user 'blah_data'@'cpe-86-80-21-54.san.res.rr.com' (using password: YES)

Any idea what could have happened and how to fix it? The only thing I think could've happened is that my support ticket dealing with node.js compatibility was executed wrong by support employees. Thanks!

1
  • If you haven't changed anything, simply contact the company. The error says you've been denied access, but we can't help you with it. Commented Oct 18, 2014 at 22:20

3 Answers 3

1

Your db user's permission has failed. The user may have been removed; the permissions may have been modified. Contact the db owner.

Sign up to request clarification or add additional context in comments.

Comments

1

So it looks like you are not authenticating: Either incorrect credentials or server needs a different method. Try disabling "sslmode" like below:

 public string GetMatchCode()
    {
        //this could be loaded from config file or other source
        string connectString = "Server=123.123.1.23;Database=blah_users;Uid=blah_data;Pwd=blahblah;sslmode=none;";
        string sql = "SELECT MAX(match_id) FROM `data_blah`";
        using (var connect = new MySqlConnection(connectString))
        using (var command = new MySqlCommand(sql, connect))
        {
            connect.Open();
            return command.ExecuteScalar().ToString();
        }
    }

That should do it

Comments

0
string sql = "SELECT MAX(match_id) FROM `data_blah`";

Isn't it supposed to be " ' " instead of " ` " surrounding "data_blah"?

1 Comment

No. Backticks are used for enclosing identifiers such as table and column names, quote for for enclosing string literals.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.