Mysql
 sql >> Teknologi Basis Data >  >> RDS >> Mysql

Perbarui pernyataan di MySQL menggunakan C #

Masalah: Anda kehilangan comma setelah location parameter dalam kueri Anda.
Solusi: Anda perlu memisahkan parameters menggunakan comma .

Saran : Gunakan parameterized queries untuk menghindari SQL Injection Attacks .

Coba ini:

private void Update(string num,string name, string quant, string location, string category, string numquery)
    {
       // "UPDATE Inventory SET Inventorynumber='"+ num +"',Inventory_Name='"+name+"', Quantity ='"+ quant+"',Location ='"+ location+"' Category ='"+ category+"' WHERE Inventorynumber ='"+ numquery +"';";
        string query = "UPDATE Inventory SET [email protected],[email protected]_Name, Quantity [email protected] ,Location [email protected],Category [email protected] WHERE Inventorynumber [email protected]";
        if (this.OpenConnection() == true)
        {
            MySqlCommand cmd = new MySqlCommand();
            cmd.CommandText = query;
            cmd.Parameters.AddWithValue("@Inventorynumber",Convert.ToInt16(num));
            cmd.Parameters.AddWithValue("@Inventory_Name",name);
            cmd.Parameters.AddWithValue("@Quantity",quant);
            cmd.Parameters.AddWithValue("@Location",location);
            cmd.Parameters.AddWithValue("@Category",category);
            cmd.Parameters.AddWithValue("@Inventorynumber",Convert.ToInt16(numquery));
            cmd.Connection = serverconnection;
            cmd.ExecuteNonQuery();
            this.CloseConnection();
            Bind();
        }
    }


  1. Database
  2.   
  3. Mysql
  4.   
  5. Oracle
  6.   
  7. Sqlserver
  8.   
  9. PostgreSQL
  10.   
  11. Access
  12.   
  13. SQLite
  14.   
  15. MariaDB
  1. Mimpi buruk database warisan MySQL terbaik

  2. Cara mengatasi ERROR 1060:Duplikat nama kolom menggunakan Tampilan -> Buat Tampilan

  3. Penamaan skema hibernasi berbeda antara OS

  4. Mysql Max dengan Grup berdasarkan kueri

  5. Bagaimana cara menangani crash database (Glassfish/MySQL)?