1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
| ublic string GetConnectionString()
{
return System.Configuration.ConfigurationManager.ConnectionStrings["csVinotheque"].ConnectionString;
}
private void UpdateQuantite(int quantite, int idprodcomm)
{
SqlConnection conn = new SqlConnection(GetConnectionString());
string sql = "Update prodcomm set quantite= @quantite where idprodcomm = @idprodcomm";
conn.Open();
try
{
SqlCommand cmd = new SqlCommand(sql, conn);
SqlParameter[] param = new SqlParameter[2];
param[0] = new SqlParameter("@quantite", SqlDbType.Int, 50);
param[1] = new SqlParameter("@idprodcomm", SqlDbType.Int, 50);
cmd.Parameters.Add(param[0]);
cmd.Parameters.Add(param[1]);
param[0].Value = quantite;
param[1].Value = idprodcomm;
//cmd.CommandType = CommandType.Text;
cmd.ExecuteNonQuery();
}
catch (System.Data.SqlClient.SqlException ex)
{
string msg = "Update Error:";
msg += ex.Message;
throw new Exception(msg);
}
finally
{
conn.Close();
}
} |
Partager