0

The Error

 private void btnGuncelle_Click(object sender, EventArgs e)
        {
            string sorgu = "UPDATE tablo_1 SET ad=@ad,soyad=@soyad,tc_kimlik=@tc_kimlik,dttarih=@dttarih,rahatsizlik=@rahatsizlik,mno=@mno WHERE mno=@no";
            komut = new SqlCommand(sorgu, baglanti);
            komut.Parameters.AddWithValue("@no", Convert.ToInt16(textBox6.Text));
            komut.Parameters.AddWithValue("@ad", txtAdi.Text);
            komut.Parameters.AddWithValue("@soyad", txtSoyadi.Text);
            komut.Parameters.AddWithValue("@tc_kimlik", txtKimlik.Text);
            komut.Parameters.AddWithValue("@rahatsizlik", txtRahatsizlik.Text);
            komut.Parameters.AddWithValue("@dttarih", dateTimePicker1.Value);
            komut.Parameters.AddWithValue("@ad2", textBox6.Text);
            baglanti.Open();
            komut.ExecuteNonQuery();
            baglanti.Close();
            HastaGetir();

When i run the program everything works fine adding data and deleting data but when i uptade the data i having this error and the name changes to hasta_id how can i fix this?

  • Query text has `@mno` which is not added to Parameters collection – Renat Jun 09 '23 at 15:39
  • You can check other answers for this error - e. g. https://stackoverflow.com/questions/8321514/input-string-was-not-in-a-correct-format indicating that the textBox6.Text string cannot be parsed as Int16 value (so we would need to know what you enter in that text box causing the error) – Twinnie Jun 09 '23 at 15:51
  • nothing change when i write everything it will cause that problem again – erkan özdemir Jun 09 '23 at 16:33

0 Answers0