开发者

MySQL local/online servers won't respond to C#/.NET

So, I'm sort of a beginner on C# and I'm working on this project that needs a connection to a MySQL database.

I got MySQL's own library for this and, just to test the connection, I wrote this code:

public object connectionTest()
{
    MySqlConnectionStringBuilder builder = new MySqlConnectionStringBuilder();
    builder.Server = "localhost";
    builder.Database = "base1";
    builder.UserID = "root";
    builder.Password = "";

    MySqlConnection conn = new MySqlConnection(builder.ConnectionString);
    conn.Open();
    return conn;
}
开发者_如何学运维

But neither the localhost database, nor the online database will respond. The password being blank or not.

My local database is installed through XAMPP - can this be a problem? Even if it was, it still should connect to the online database. Is there any restriction for C# to work with MySQL?

Using C#'s SqlConnection instead of MySqlConnection, the conn object is always initialized with its State attribute set to "Closed". I'm not sure if this happens because the database server isn't responding as with the MySqlConnection class or because of something else.

Any thoughts?


Can you access the MySQL database via MySQL Administrator or MySQL Query Browser? Perhaps it is not running as a service and thus is not available to the MySQL connection.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜