sekullarx
Öğrenci
- Katılım
- 3 Kasım 2022
- Mesajlar
- 5
- Reaksiyon puanı
- 0
- Puanları
- 1
- Yaş
- 17
sa beyler,
Kodlarım bu şekilde 2 ayrı try catch finally kullandımi ikiside aynı hatayı veriyor hatalar şöyle: kayittarihekle() kodunda incorrect syntax near ')' hatası
kayitekle() incorrect syntax near '@musteriid' hatası alıyorum nasıl çözerim?
C#:
public void kayittarihekle()
{
try
{
baglanti = new SqlConnection(@"Data Source =.\SQLEXPRESS; Initial Catalog = Oteltakip2; Integrated Security = True");
baglanti.Open();
cmd = new SqlCommand("insert into tableOtelTakipTarih values @musteriid, @gelentarih, @gidentarih",baglanti);
cmd.Parameters.Add("@musteriid", textBox1.Text);
cmd.Parameters.Add("@gelentarih", dateTimePicker1.Value);
cmd.Parameters.Add("@gidentarih", dateTimePicker2.Value);
cmd.ExecuteNonQuery();
}
catch(Exception ex)
{
MessageBox.Show("(DTP)SQL Query Error:" + ex.Message);
}
finally
{
baglanti.Close();
}
}
public void kayitekle()
{
try
{
baglanti = new SqlConnection(@"Data Source =.\SQLEXPRESS; Initial Catalog = Oteltakip2; Integrated Security = True");
baglanti.Open();
string ekle;
ekle = "insert into tableOtelTakipTarih" + "values ('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "')";
SqlCommand cmd = new SqlCommand(ekle, baglanti);
cmd.ExecuteNonQuery();
MessageBox.Show("Kayıt ekleme işlemi başarılı!", "Uyarı", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch(Exception ex)
{
MessageBox.Show("(TXİLK3)SQL Query error:" + ex.Message);
}
finally
{
baglanti.Close();
}
kayitekle() incorrect syntax near '@musteriid' hatası alıyorum nasıl çözerim?