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 find any row has updated or not after executing the update query? [modified]

In MSSQL, how to find any row has updated or not after executing the update query? [modified]

Scheduled Pinned Locked Moved C#
databasesql-serverhelptutorialquestion
4 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, This is the 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"); da.Update(ds, "CompanyInfo")- fires an exception ("Update unable to find TableMapping['CompanyInfo'] or DataTable 'CompanyInfo'."). Please suggest the idea. Thanks and Regards

    modified on Saturday, January 31, 2009 3:23 AM

    W C N 3 Replies Last reply
    0
    • S S a n d y

      Hi all, This is the 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"); da.Update(ds, "CompanyInfo")- fires an exception ("Update unable to find TableMapping['CompanyInfo'] or DataTable 'CompanyInfo'."). Please suggest the idea. Thanks and Regards

      modified on Saturday, January 31, 2009 3:23 AM

      W Offline
      W Offline
      Wendelius
      wrote on last edited by
      #2

      The first thing is that the constructor of SqlDataAdapter expects to receive a SELECT string, not an UPDATE string. Also when using SqlDataAdapter you don't concatenate values to the statement (actually you should never do this. It seems that you've mixed SqlDataAdapter with SqlCommand. So: - create a proper select sattement - use that when constructing - if you want that the update statement is generated automatically, make sure that the select command contains key column from your table. Also use SqlCommandBuilder to create the select command - otherwise create a SqlCommand for UPDATE and place that in SqlDataAdapter.UpdateCommand After those steps you can try to call the Update method of the SqlDataAdapter.

      The need to optimize rises from a bad design.My articles[^]

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

        Hi all, This is the 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"); da.Update(ds, "CompanyInfo")- fires an exception ("Update unable to find TableMapping['CompanyInfo'] or DataTable 'CompanyInfo'."). Please suggest the idea. Thanks and Regards

        modified on Saturday, January 31, 2009 3:23 AM

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

        Your code is such that I could erase your database any time i wanted. Please tell me this is a student assignment and not paid work. Your code is stupid. You fill a dataset and then pass it through the data adapter - why ? You just want to run this SQL, you need no dataset for that. Are you making it up as you go along, or do you actually know somethign about C# or programming in general ?

        Christian Graus Driven to the arms of OSX by Vista.

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

          Hi all, This is the 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"); da.Update(ds, "CompanyInfo")- fires an exception ("Update unable to find TableMapping['CompanyInfo'] or DataTable 'CompanyInfo'."). Please suggest the idea. Thanks and Regards

          modified on Saturday, January 31, 2009 3:23 AM

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

          hi.... Just follow this link.... about DataAdapter

          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