Veri tabanına veri eklerken "input string was not in a correct format" hatası

erkan67

Kilopat
Katılım
24 Haziran 2019
Mesajlar
424
Çözümler
4
Merhaba projemi yaparken böyle bir sorunla karsilastim. Bunu nasıl cözerim? Simdiden teşekkürler.

C#:
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("@hasta_no", Convert.ToInt32(txtAdi.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", txtAdi.Text);
            baglanti.Open();
            komut.ExecuteNonQuery();
            baglanti.Close();
            HastaGetir();

hasta.png
 
Son düzenleyen: Moderatör:
dataGridView cell enter eventını şu şekilde değişir misiniz?

C#:
private void dataGridView1_CellEnter(object sender, DataGridViewCellEventArgs e)
{
    txtHastaNO.Text = dataGridView1.CurrentRow.Cells[0].Value.ToString();
    txtAdi.Text = dataGridView1.CurrentRow.Cells[1].Value.ToString();
    txtSoyadi.Text = dataGridView1.CurrentRow.Cells[2].Value.ToString();
    txtKimlik.Text = dataGridView1.CurrentRow.Cells[3].Value.ToString();
    txtRahatsizlik.Text = dataGridView1.CurrentRow.Cells[4].Value.ToString();
}
 
DataGridView cell enter Event'ını şu şekilde değişir misiniz?

C#:
private void dataGridView1_CellEnter(object sender, DataGridViewCellEventArgs e)
{
 txtHastaNO.Text = dataGridView1.CurrentRow.Cells[0].Value.ToString();
 txtAdi.Text = dataGridView1.CurrentRow.Cells[1].Value.ToString();
 txtSoyadi.Text = dataGridView1.CurrentRow.Cells[2].Value.ToString();
 txtKimlik.Text = dataGridView1.CurrentRow.Cells[3].Value.ToString();
 txtRahatsizlik.Text = dataGridView1.CurrentRow.Cells[4].Value.ToString();
}

Maalesef yine aynisini yapti.
 

Technopat Haberler

Yeni konular

Geri
Yukarı