if (comboBox2.Text == "A") {
baglanti.Open();
cmd = new MySqlCommand("SELECT `Sifreler`FROM `9sinifgiris` WHERE 1", baglanti);
dr = cmd.ExecuteReader();
if (dr.Read()) // Veriyi çektik
{
if (textBox1.Text == dr["Sifreler"].ToString()) {
baglanti.Close();
MessageBox.Show("Parola aynı giriş yap");
button1.Enabled = true;
baglanti.Open();
cmd = new MySqlCommand("insert into 9sinifgiris (9A) Values ('TestText')", baglanti);
cmd.ExecuteNonQuery(); // GETTİNG ERROR FROM HERE
} else {
MessageBox.Show("Parola yanlış");
textBox1.Clear();
}
}
baglanti.Close();
}
I'm getting an error from cmd.ExecuteNonQuery();
:
MySql.Data.MySqlClient.MySqlException: 'Field 'Sifreler' doesn't have a default value'
I don't want to write Sifreler
into the database, but the error is with this line.
I used to work with this code for my old project and it worked well. I want to add the text I write into the database.
Please help.