請幫助我,當我更新e時出錯!更新過程中未處理MySqlException
bdDataSet = new DataSet();
//Define string de conexão
bdConn = new MySqlConnection("Server=xxxxxxxxx;Database=xxxxxxx;Uid=xxxxxxx;Pwd=xxxxxxxx");
var command = bdConn.CreateCommand();
//Abre conecção
try
{
bdConn.Open();
}
catch
{
MessageBox.Show("Impossível estabelecer conexão");
}
//Verifica se a conexão está aberta
if (bdConn.State == ConnectionState.Open)
{
//ENCONTRA USUARIO
command.CommandText = "SELECT * FROM users WHERE [email protected] and [email protected]";
command.Parameters.Add("@email", MySqlDbType.VarChar).Value = textBoxUser.Text;
command.Parameters.Add("@senha", MySqlDbType.VarChar).Value = textBoxPass.Text;
MySqlDataReader reader = command.ExecuteReader();
if (reader.Read())
{
string email = reader.GetString("email");
if (Convert.IsDBNull(reader["hd_id"]))
{
//ADD HD ID NO D
MySqlCommand sql2 = new MySqlCommand("UPDATE users SET [email protected] WHERE [email protected]", bdConn);
sql2.Parameters.Add("@hdid", MySqlDbType.VarChar).Value = HardDrive.GetHDDSerialNo();
sql2.Parameters.Add("@email", MySqlDbType.VarChar).Value = email;
sql2.ExecuteReader();
}
if (reader.GetString("hd_id") != null)
{
MessageBox.Show("Tem HD");
}
}
else
{
MessageBox.Show("Usuários e/ou Senha Invalido");
}
bdConn.Close();
}
讓我有錯誤在這行
sql2.ExecuteReader();
請helpe做解決這個問題!對不起,我的英語來自巴西。我已經盡了一切努力來做這個查詢,但我根本不能希望你們中的任何人都能幫助我!
任何時候你「出現錯誤」,你必須告訴我們是什麼錯誤。 –
什麼是錯誤? –