1
コードをデバッグするとconnection.Open();がハングするだけです。C#でmysql dbに接続しようとしています
私はコネクタを使用しています - MySql.Data.MySqlClientを使用しています。
ありがとうございます。
string strProvider = "Data Source=" + host + ";Database=" + database + ";User ID=" + user + ";Password=" + password;
MySqlConnection connection = new MySqlConnection(strProvider);
MySqlCommand command = connection.CreateCommand();
MySqlDataReader Reader;
command.CommandText = "select * from products";
connection.Open();
Reader = command.ExecuteReader();
while (Reader.Read())
{
string thisrow = "";
for (int i = 0; i < Reader.FieldCount; i++)
thisrow += Reader.GetValue(i).ToString() + ",";
listBox1.Items.Add(thisrow);
}
connection.Close();
ネットワークの問題のためにあなたの接続文字列を変更する必要がhttp://www.connectionstrings.com/mysql
を助けますか?ファイアウォール? –
command.CommandTimeoutを設定して、タイムアウトが発生するかどうか確認してください。 これを行う場合は、telnetまたはnetcatを使用してSQLiteに接続できるかどうかを確認してください。 – TCS