2014-10-29 45 views
-1
public void EtiketVerisiKaydiGuncelle() 
    { 
     try 
     { 
      string sorgu = "UPDATE EtiketVerisi SET Tarih='" + this.TARIH + "', NetKG='" + this.NETKG + "', MalinCinsi='" + this.MAL + "', Musteri='" + this.MUSTERI + "', Renk='" + this.RENK + "', PartiNo='" + this.PARTINO + "', RollNo='" + this.ROLLNO + "', Barkod='" + this.BARKOD + "', WHERE Kimlik=" + this.Kimlik; 

      if (bag.State == ConnectionState.Closed) 
       bag.Open(); 
      komut.Connection = bag; 
      komut.CommandText = sorgu; 
      komut.ExecuteNonQuery(); 
      MessageBox.Show("Kayıt Güncellendi"); 
     } 
     catch (Exception ex) 
     { 
      MessageBox.Show(ex.Message); 
     } 
    } 

当我尝试更新数据库上的信息时,我收到的错误是Update语句中的语法错误。c#数据库中的语法错误

+0

你相信吗? – 2014-10-29 12:49:05

回答

4

你之前有一个逗号您的WHERE子句

"', WHERE Kimlik=" 

还应考虑使用参数为您离开自己开到'SQL Injection` SQL注入攻击

+0

非常感谢你在这一点上SQL注入攻击对我们来说不是很重要:) – 2014-10-29 11:13:42