my sql table is not updated, when i do???!!, the codes are as folow:
string connectionStringid = ConfigurationManager.ConnectionStrings["CustomerDB"].ConnectionString; connad = new SqlConnection(connectionStringad); commandad = new SqlCommand("", connad);
which are class variables. the folowing codes for insert and update, insert works, but not update???!!:
public static string AddAd(Customerad customerad, int Id) { string result; string q = string.Format("select * from customerad1 where Email='{0}' and Title='{1}'", customerad.Email, customerad.Title); try { connad.Open(); commandad.CommandText = q; int amountOfUsers = Convert.ToInt32(commandad.ExecuteScalar()); if (amountOfUsers < 1) //new user { commandad.CommandText = @"INSERT INTO customerad1 (Name, Email, Phone, Country, ZipCode, Category, Title, Price, Images, Date_Time, Description, Bussiness, Payment) VALUES ('" + customerad.Name + "','" + customerad.Email + "','" + customerad.Phone + "','" + customerad.Country + "','" + customerad.ZipCode + "','" + customerad.Category + "','" + customerad.Title + "','" + customerad.Price + "','" + customerad.Images + "','" + customerad.Date_Time + "','" + customerad.Description + "','" + customerad.Bussiness + "','" + customerad.Payment + "')"; commandad.ExecuteNonQuery(); result = "Ad registered!"; } else //user exist { commandad.CommandText = @"UPDATE customerad1 SET ([Name]='" + customerad.Name + "', [Email]='" + customerad.Email + "', " + "[Phone]='" + customerad.Phone + "', " + "[Country]='" + customerad.Country + "', [ZipCode]='" + customerad.ZipCode + "', [Category]='" + customerad.Category + "', " + "[Title]='" + customerad.Title + "', [Price]='" + customerad.Price + "', [Images]='" + customerad.Images + "', " + "[Date_Time]='" + customerad.Date_Time + "', [Description]='" + customerad.Description + "', [Bussiness]='" + customerad.Bussiness + "', [Payment]='" + customerad.Payment + "') where [Id]='" + Id + "' "; commandad.ExecuteNonQuery(); result = "Ad updated!"; } } }
i cannot find the problem... please help me, i appreciate... kind regards