Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. why update data is wrong..

why update data is wrong..

Scheduled Pinned Locked Moved C#
databasequestionannouncement
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    angels777
    wrote on last edited by
    #1

    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

    J 1 Reply Last reply
    0
    • A angels777

      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

      J Offline
      J Offline
      Jacky Yiu
      wrote on last edited by
      #2

      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??

      A 1 Reply Last reply
      0
      • J Jacky Yiu

        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??

        A Offline
        A Offline
        angels777
        wrote on last edited by
        #3

        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 ??

        A 1 Reply Last reply
        0
        • A angels777

          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 ??

          A Offline
          A Offline
          angels777
          wrote on last edited by
          #4

          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 this UPDATE [Table1] SET name = @name, address= @address, phone = @phone WHERE (Id = @Original_Id); SELECT Id, name,address,phone FROM [User] WHERE (Id = @Id)

          J 1 Reply Last reply
          0
          • A angels777

            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 this UPDATE [Table1] SET name = @name, address= @address, phone = @phone WHERE (Id = @Original_Id); SELECT Id, name,address,phone FROM [User] WHERE (Id = @Id)

            J Offline
            J Offline
            Jacky Yiu
            wrote on last edited by
            #5

            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);

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups