why update data is wrong..
-
hi i use the below code to update.. DataTable store = new DataTable(); store = son.Table1; father.Update(name.Text, ......) but visual prompt me soemthing weird when i put " , " after name.text in my Table1 only have "id, name, address" . why after "," it prompt me update(string name, string address, int Original_ID, string Origianl_name, string Original_address, int ID) i cant update if i din all those things.. something is wrong with my database.. ? i checked.. it shown only 3 fields
-
hi i use the below code to update.. DataTable store = new DataTable(); store = son.Table1; father.Update(name.Text, ......) but visual prompt me soemthing weird when i put " , " after name.text in my Table1 only have "id, name, address" . why after "," it prompt me update(string name, string address, int Original_ID, string Origianl_name, string Original_address, int ID) i cant update if i din all those things.. something is wrong with my database.. ? i checked.. it shown only 3 fields
if your "father" (is it a good variable name?? :doh: ) mean SqlDataAdapter, why don't you update the whole dataset or datatable??? and SqlDataAdapter.Update will be execute the UpdateCommand that predefine in the SqlDataAdapter.UpdateCommand, did you set the command correctly??
-
if your "father" (is it a good variable name?? :doh: ) mean SqlDataAdapter, why don't you update the whole dataset or datatable??? and SqlDataAdapter.Update will be execute the UpdateCommand that predefine in the SqlDataAdapter.UpdateCommand, did you set the command correctly??
-
do u mean i need to add query for update for my dataset ? i did not set the command.. cos when i put " father. " after the . it shown me the update.. the update already there// ? should i add that query ??
i try to add the update query at the tableadapter query configuration wizards. it show like this
UPDATE [Table1] SET [name] = @name, [address] = @address, [phone] = @phone WHERE (([id] = @Original_id) AND ((@IsNull_name = 1 AND [name] IS NULL) OR ([name] = @Original_name)) AND ((@IsNull_address = 1 AND [address] IS NULL) OR ([address] = @Original_address)) AND ((@IsNull_phone = 1 AND [phone] IS NULL) OR ([phone] = @Original_phone))); SELECT id, name, address, phone FROM Table1 WHERE (id = @id)
why not like thisUPDATE [Table1] SET name = @name, address= @address, phone = @phone WHERE (Id = @Original_Id); SELECT Id, name,address,phone FROM [User] WHERE (Id = @Id)
-
i try to add the update query at the tableadapter query configuration wizards. it show like this
UPDATE [Table1] SET [name] = @name, [address] = @address, [phone] = @phone WHERE (([id] = @Original_id) AND ((@IsNull_name = 1 AND [name] IS NULL) OR ([name] = @Original_name)) AND ((@IsNull_address = 1 AND [address] IS NULL) OR ([address] = @Original_address)) AND ((@IsNull_phone = 1 AND [phone] IS NULL) OR ([phone] = @Original_phone))); SELECT id, name, address, phone FROM Table1 WHERE (id = @id)
why not like thisUPDATE [Table1] SET name = @name, address= @address, phone = @phone WHERE (Id = @Original_Id); SELECT Id, name,address,phone FROM [User] WHERE (Id = @Id)
it's prevent if there has 2 users editing the record, if A has submit the update command, then B SHOULD NOT be update and the program should handle the roll back. a easy example, if 2 people want to buy a movie ticket online, and they were select for the same seat, if A has submit the data, could B update the DB also?? if the update command is ready, just provide the dataset/datatable to the adapter is fine in your case, it should be: father.Update(son);