when im trying to use this code, vs shows me this error:
< Unclosed quotation mark after the character string '@bc'.
Incorrect syntax near '@bc'.>
does anybody have idea where is problem?
C# internal static void EditProduct(string txtBarCode, string txtArtNumber, string txtProductName, string txtPrice, string txtComment, decimal NumericUpDown1, string PriceWithOutAWD, string txtSelfPrice)
{
SqlConnection con = new SqlConnection(ConnectionString);
SqlCommand cmd = new SqlCommand("UPDATE Products SET BarCode = @BarCode, ArtNumber = @ArtNumber, ProductName = @ProductName, Price = @Price, SelfPrice = @SelfPrice, PriceWithOutAWD = @PriceWithOutAWD, UnitsInStock = @UnitsInStock, Comment = @Comment WHERE BarCode = '@bc", con);
cmd.Parameters.Add(new SqlParameter("@BarCode", txtBarCode));
cmd.Parameters.Add(new SqlParameter("@ArtNumber", txtArtNumber));
cmd.Parameters.Add(new SqlParameter("@ProductName", txtProductName));
cmd.Parameters.Add(new SqlParameter("@Price", txtPrice));
cmd.Parameters.Add(new SqlParameter("@SelfPrice", txtSelfPrice));
cmd.Parameters.Add(new SqlParameter("@PriceWithOutAWD", PriceWithOutAWD));
cmd.Parameters.Add(new SqlParameter("@UnitsInStock", NumericUpDown1));
cmd.Parameters.Add(new SqlParameter("@Comment", txtComment));
cmd.Parameters.Add(new SqlParameter("@bc", txtBarCode));
try
{
con.Open();
cmd.ExecuteNonQuery();
}
finally
{
con.Close();
}
}
|
shukumei holmes2 pointsPosted Oct 26, 2010, 12:19 PM EDT
Try this.
SqlCommand cmd = new SqlCommand("UPDATE Products SET BarCode = @BarCode, ArtNumber = @ArtNumber, ProductName = @ProductName, Price = @Price, SelfPrice = @SelfPrice, PriceWithOutAWD = @PriceWithOutAWD, UnitsInStock = @UnitsInStock, Comment = @Comment WHERE BarCode = '@bc' ", con);