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. .NET (Core and Framework)
  4. Tracing SQL generated by DataAdapter.Update(dataset)

Tracing SQL generated by DataAdapter.Update(dataset)

Scheduled Pinned Locked Moved .NET (Core and Framework)
databasequestioncsharphelpannouncement
7 Posts 3 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.
  • J Offline
    J Offline
    Jean Louis Leroy
    wrote on last edited by
    #1

    Hello, How can I see the SQL generated by DataAdapter.Update(dataset) - if any. Here's a bit of context: I have a (typed) table adaptor (generated using Visual C# 2008) that fills a table from a query on a join (i.e. select all rows from a table that have a counterpart in another table). I managed to handle insertions (i.e. insert in the other table). Now for deletion...I set the DeleteCommand. I remove all the rows from the dataset and I call Update(). Nothing happens. Not even an exception. Either there's a problem with my DeleteCommand or it's never called. How can I find out ? Thanks, Jean-Louis

    L P 2 Replies Last reply
    0
    • J Jean Louis Leroy

      Hello, How can I see the SQL generated by DataAdapter.Update(dataset) - if any. Here's a bit of context: I have a (typed) table adaptor (generated using Visual C# 2008) that fills a table from a query on a join (i.e. select all rows from a table that have a counterpart in another table). I managed to handle insertions (i.e. insert in the other table). Now for deletion...I set the DeleteCommand. I remove all the rows from the dataset and I call Update(). Nothing happens. Not even an exception. Either there's a problem with my DeleteCommand or it's never called. How can I find out ? Thanks, Jean-Louis

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Start the Sql profiler and connect to the server that you want to trace. Alternatively, you could add a trace yourself. Start here[^] :)

      I are Troll :suss:

      J 1 Reply Last reply
      0
      • L Lost User

        Start the Sql profiler and connect to the server that you want to trace. Alternatively, you could add a trace yourself. Start here[^] :)

        I are Troll :suss:

        J Offline
        J Offline
        Jean Louis Leroy
        wrote on last edited by
        #3

        I don't have SQL Profiler at the moment, I was wondering if it's possible to do it from within the program, e.g. if there is a logging facility built in datasets. J-L

        L 1 Reply Last reply
        0
        • J Jean Louis Leroy

          I don't have SQL Profiler at the moment, I was wondering if it's possible to do it from within the program, e.g. if there is a logging facility built in datasets. J-L

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          AFAIK not, but you should be able to start a trace using TSQL-commands, without having the Profiler. The statements are listed here[^], with some short explanation.

          I are Troll :suss:

          1 Reply Last reply
          0
          • J Jean Louis Leroy

            Hello, How can I see the SQL generated by DataAdapter.Update(dataset) - if any. Here's a bit of context: I have a (typed) table adaptor (generated using Visual C# 2008) that fills a table from a query on a join (i.e. select all rows from a table that have a counterpart in another table). I managed to handle insertions (i.e. insert in the other table). Now for deletion...I set the DeleteCommand. I remove all the rows from the dataset and I call Update(). Nothing happens. Not even an exception. Either there's a problem with my DeleteCommand or it's never called. How can I find out ? Thanks, Jean-Louis

            P Online
            P Online
            PIEBALDconsult
            wrote on last edited by
            #5

            DataAdapters can only do very simple things -- e.g. working with only one table, with a primary key -- I don't think they have the smarts to Update joined data. Experienced developers don't use them.

            J 1 Reply Last reply
            0
            • P PIEBALDconsult

              DataAdapters can only do very simple things -- e.g. working with only one table, with a primary key -- I don't think they have the smarts to Update joined data. Experienced developers don't use them.

              J Offline
              J Offline
              Jean Louis Leroy
              wrote on last edited by
              #6

              > DataAdapters [...] -- I don't think they have the smarts to Update joined data. That's why I provide an InsertCommand (which works fine) and a DeleteCommand (which isn't called :confused:). I won't need an UpdateCommand because I'm actually managing two listboxes to update an underlying link table. > Experienced developers don't use them. I'm not that experienced yet :laugh: I'm learning and trying to do things the proper .NET way, e.g. use DataSets instead of raw SQL. Also, typed datasets look like a good idea. What would you recommend ? J-L

              P 1 Reply Last reply
              0
              • J Jean Louis Leroy

                > DataAdapters [...] -- I don't think they have the smarts to Update joined data. That's why I provide an InsertCommand (which works fine) and a DeleteCommand (which isn't called :confused:). I won't need an UpdateCommand because I'm actually managing two listboxes to update an underlying link table. > Experienced developers don't use them. I'm not that experienced yet :laugh: I'm learning and trying to do things the proper .NET way, e.g. use DataSets instead of raw SQL. Also, typed datasets look like a good idea. What would you recommend ? J-L

                P Online
                P Online
                PIEBALDconsult
                wrote on last edited by
                #7

                Jean-Louis Leroy wrote:

                the proper .NET way, e.g. use DataSets instead of raw SQL.

                That's the lazy way; it leads to poor quality and frustrations like you have now.

                Jean-Louis Leroy wrote:

                What would you recommend ?

                Just use SQL; it sounds like you know how. Read this[^].

                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