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. In MSSQL, how to know update query will affect any rows or not.

In MSSQL, how to know update query will affect any rows or not.

Scheduled Pinned Locked Moved C#
questiondatabasesql-servertutorialannouncement
8 Posts 4 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.
  • S Offline
    S Offline
    S a n d y
    wrote on last edited by
    #1

    Hi all, I am trying to update a row through update query using SqlDataAdapter and DataSet. How can I know, this update query has made any changes in any row or not? Thanks and Regards.

    S N 2 Replies Last reply
    0
    • S S a n d y

      Hi all, I am trying to update a row through update query using SqlDataAdapter and DataSet. How can I know, this update query has made any changes in any row or not? Thanks and Regards.

      S Offline
      S Offline
      Spunky Coder
      wrote on last edited by
      #2

      SqlDataAdapter.Update(DataSet) returns an System.Int32 value which gives the number of rows successfully updated from the DataSet.

      "Don't worry if it doesn't work right. If everything did, you'd be out of a job." (Mosher's Law of Software Engineering)

      S 1 Reply Last reply
      0
      • S S a n d y

        Hi all, I am trying to update a row through update query using SqlDataAdapter and DataSet. How can I know, this update query has made any changes in any row or not? Thanks and Regards.

        N Offline
        N Offline
        Najmal
        wrote on last edited by
        #3

        Hi............. Its Simple.... Just Keep the return value.... if it zero ... then No change.... else thats much change.... Just click If u wantto Know more... http://msdn.microsoft.com/en-us/library/at8a576f.aspx\[^\]

        S 1 Reply Last reply
        0
        • S Spunky Coder

          SqlDataAdapter.Update(DataSet) returns an System.Int32 value which gives the number of rows successfully updated from the DataSet.

          "Don't worry if it doesn't work right. If everything did, you'd be out of a job." (Mosher's Law of Software Engineering)

          S Offline
          S Offline
          S a n d y
          wrote on last edited by
          #4

          Thanks for your reply but it can't work or I can not understand how to use this. Please describe with a little example. It fires an exception (Update unable to find TableMapping['Table'] or DataTable 'Table'.).

          S 1 Reply Last reply
          0
          • N Najmal

            Hi............. Its Simple.... Just Keep the return value.... if it zero ... then No change.... else thats much change.... Just click If u wantto Know more... http://msdn.microsoft.com/en-us/library/at8a576f.aspx\[^\]

            S Offline
            S Offline
            S a n d y
            wrote on last edited by
            #5

            Thanks for your reply but I can not understand how to use this. I am using given refrence link but it fires an exception (Update unable to find TableMapping['Table'] or DataTable 'Table'.).

            C 1 Reply Last reply
            0
            • S S a n d y

              Thanks for your reply but I can not understand how to use this. I am using given refrence link but it fires an exception (Update unable to find TableMapping['Table'] or DataTable 'Table'.).

              C Offline
              C Offline
              Christian Graus
              wrote on last edited by
              #6

              It sounds like the basic issue is one of incompetence. Have you looked at the link provided and the code in the MSDN and compared it to your own ? If you want us to fix your code, have you considered posting it, so we can see where your error is ?

              Christian Graus Driven to the arms of OSX by Vista.

              S 1 Reply Last reply
              0
              • S S a n d y

                Thanks for your reply but it can't work or I can not understand how to use this. Please describe with a little example. It fires an exception (Update unable to find TableMapping['Table'] or DataTable 'Table'.).

                S Offline
                S Offline
                Spunky Coder
                wrote on last edited by
                #7

                Use the Update overloaded one...i mean

                SqlAdapter sa = new SqlAdapter();

                //Provide the command name or all the required stuff

                //Call Update(DataSet dataset, string srctable)

                int j = sa.Update(ds,"TableName"); ///j contains the number of rows updated.

                "Don't worry if it doesn't work right. If everything did, you'd be out of a job." (Mosher's Law of Software Engineering)

                1 Reply Last reply
                0
                • C Christian Graus

                  It sounds like the basic issue is one of incompetence. Have you looked at the link provided and the code in the MSDN and compared it to your own ? If you want us to fix your code, have you considered posting it, so we can see where your error is ?

                  Christian Graus Driven to the arms of OSX by Vista.

                  S Offline
                  S Offline
                  S a n d y
                  wrote on last edited by
                  #8

                  This is my code, where the problem occurs. SqlDataAdapter da = new SqlDataAdapter("UPDATE CompanyInfo SET CompName='abc' where CompID='" + CompID.Text.Trim() + "'", con); DataSet ds = new DataSet(); da.Fill(ds); int gh = da.Update(ds, "CompanyInfo"); Exception fires on that code is ("Update unable to find TableMapping['CompanyInfo'] or DataTable 'CompanyInfo'."). Please suggest for the wrong code. Thanks and Regards

                  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