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. Web Development
  3. ASP.NET
  4. Limited Update in Table

Limited Update in Table

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netdatabasehelptutorial
13 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.
  • G Girish481

    No, because i think it will unnecessary increase network traffic and more request to server though.

    S Offline
    S Offline
    saanj
    wrote on last edited by
    #4

    Ok that's fine. In the button click event, just check whether the text box's value equals to the datatable rows' value or not. if it is not then only update the column else don't. Just checkout the sample code:

    if(dataSet.Tables[0].Rows[8][column_name] != textBox8.Text)
    {
    dataSet.Tables[0].Rows[8][column_name] = textBox8.Text
    }

    So the datatable will be updated only when the value differs from the earlier one and that means that the text box's value is changed. Is it clear? Revert back for any clarification.

    There is no foolish question, there is no final answer...

    G 1 Reply Last reply
    0
    • S saanj

      Ok that's fine. In the button click event, just check whether the text box's value equals to the datatable rows' value or not. if it is not then only update the column else don't. Just checkout the sample code:

      if(dataSet.Tables[0].Rows[8][column_name] != textBox8.Text)
      {
      dataSet.Tables[0].Rows[8][column_name] = textBox8.Text
      }

      So the datatable will be updated only when the value differs from the earlier one and that means that the text box's value is changed. Is it clear? Revert back for any clarification.

      There is no foolish question, there is no final answer...

      G Offline
      G Offline
      Girish481
      wrote on last edited by
      #5

      Thanks for your reply; but at the last for saving the new values in the database; i will have to call adapter.update(ds); it means it will fire the complete update command. And moreover i am using following code to create dataset: Dim ods As New DataSet ods.ReadXml("C:\Inetpub\wwwroot\Exam2\Temp.xml") So, 1.will it work on the dataset and update the table ? 2.and i will have to call adapter.update(ods); means a complete update command ? What i am seeking, that after changing the values in textboxes; only those columns should be updated; rather than a complete row. Regards Girish Sharma

      S 1 Reply Last reply
      0
      • G Girish481

        Thanks for your reply; but at the last for saving the new values in the database; i will have to call adapter.update(ds); it means it will fire the complete update command. And moreover i am using following code to create dataset: Dim ods As New DataSet ods.ReadXml("C:\Inetpub\wwwroot\Exam2\Temp.xml") So, 1.will it work on the dataset and update the table ? 2.and i will have to call adapter.update(ods); means a complete update command ? What i am seeking, that after changing the values in textboxes; only those columns should be updated; rather than a complete row. Regards Girish Sharma

        S Offline
        S Offline
        saanj
        wrote on last edited by
        #6

        The you can probably look a for writing a sql query for updating fields. You can run a for loop to check the values and after that fire the sql query only for those columns whose values are changed. DataAdapter.Update may not be a best case in this scenario.

        There is no foolish question, there is no final answer...

        G 1 Reply Last reply
        0
        • S saanj

          The you can probably look a for writing a sql query for updating fields. You can run a for loop to check the values and after that fire the sql query only for those columns whose values are changed. DataAdapter.Update may not be a best case in this scenario.

          There is no foolish question, there is no final answer...

          G Offline
          G Offline
          Girish481
          wrote on last edited by
          #7

          Here one idea/approach may be using javascript. A javascript function, which will be called on textbox change event (if value changed then) with create and append a update command and then fire that update command on cliking the update button; but i do'nt have knowledge in js; just have the idea how it may worked.

          S 1 Reply Last reply
          0
          • G Girish481

            Here one idea/approach may be using javascript. A javascript function, which will be called on textbox change event (if value changed then) with create and append a update command and then fire that update command on cliking the update button; but i do'nt have knowledge in js; just have the idea how it may worked.

            S Offline
            S Offline
            saanj
            wrote on last edited by
            #8

            You will not be able to access the value which is set in javascript because on the server side those values will be lost.

            There is no foolish question, there is no final answer...

            G 2 Replies Last reply
            0
            • S saanj

              You will not be able to access the value which is set in javascript because on the server side those values will be lost.

              There is no foolish question, there is no final answer...

              G Offline
              G Offline
              Girish481
              wrote on last edited by
              #9

              Then please tell me the best and easy method to get update command for selected (changed values) columns. Kind Regards Girish Sharma

              1 Reply Last reply
              0
              • S saanj

                You will not be able to access the value which is set in javascript because on the server side those values will be lost.

                There is no foolish question, there is no final answer...

                G Offline
                G Offline
                Girish481
                wrote on last edited by
                #10

                Then please provide me the solution by which i can get one update command for only those columns whose textbox values has been changed by user. Kind Regards Girish Sharma

                S 1 Reply Last reply
                0
                • G Girish481

                  Then please provide me the solution by which i can get one update command for only those columns whose textbox values has been changed by user. Kind Regards Girish Sharma

                  S Offline
                  S Offline
                  saanj
                  wrote on last edited by
                  #11

                  I already told you this: http://www.codeproject.com/Forums/12076/ASP-NET.aspx?fid=12076&select=3081044&fr=75#xx3081044xx[^]

                  There is no foolish question, there is no final answer...

                  G 1 Reply Last reply
                  0
                  • S saanj

                    I already told you this: http://www.codeproject.com/Forums/12076/ASP-NET.aspx?fid=12076&select=3081044&fr=75#xx3081044xx[^]

                    There is no foolish question, there is no final answer...

                    G Offline
                    G Offline
                    Girish481
                    wrote on last edited by
                    #12

                    But further you are agreeed that adapter.update is not best in this scnerio; so still waiting for your reply please.

                    S 1 Reply Last reply
                    0
                    • G Girish481

                      But further you are agreeed that adapter.update is not best in this scnerio; so still waiting for your reply please.

                      S Offline
                      S Offline
                      saanj
                      wrote on last edited by
                      #13

                      I am not telling you to use DataAdapter.Update. Run a for loop and check if the textbox's value differs from the datatable's (dataset.tables[0]) value or not. if it differs then create a sqlconnection object and associate it to a sqlcommand object. Then fire a sql update query by using sqlcommand.executenonquery method. by this way, you will fire sql update for only those rows whose values are changed in the textboxes.

                      There is no foolish question, there is no final answer...

                      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