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. Database & SysAdmin
  3. Database
  4. Changing CommandText changes Parameters

Changing CommandText changes Parameters

Scheduled Pinned Locked Moved Database
csharpvisual-studiotutorialquestion
14 Posts 5 Posters 2 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.
  • T Offline
    T Offline
    Trevortni
    wrote on last edited by
    #1

    I'm trying to edit the CommandText for the Insert Command in a TableAdapter in the Designer in vb.net. Whenever I make changes to the CommandText, Visual Studio (2008) automagically changes the Parameters to a Collection consisting of one Parameter that existed before editing the Command, immersed in a sea of complete garbage Parameters, and then I either have to undo (unless this was the first thing I tried editing, in which case I have to close the Designer to discard changes and reopen it) or manually change ALL the Parameters back to something that isn't complete garbage. Has anybody seen anything like this, or know how to stop Visual Studio from murdering my carefully tended Parameters? Any way to change the CommandText without finding yet another reason to curse the name of M$ would be greatly appreciated.

    P A M 3 Replies Last reply
    0
    • T Trevortni

      I'm trying to edit the CommandText for the Insert Command in a TableAdapter in the Designer in vb.net. Whenever I make changes to the CommandText, Visual Studio (2008) automagically changes the Parameters to a Collection consisting of one Parameter that existed before editing the Command, immersed in a sea of complete garbage Parameters, and then I either have to undo (unless this was the first thing I tried editing, in which case I have to close the Designer to discard changes and reopen it) or manually change ALL the Parameters back to something that isn't complete garbage. Has anybody seen anything like this, or know how to stop Visual Studio from murdering my carefully tended Parameters? Any way to change the CommandText without finding yet another reason to curse the name of M$ would be greatly appreciated.

      P Offline
      P Offline
      PIEBALDconsult
      wrote on last edited by
      #2

      I expect that's what it's supposed to do. Never use a DataAdapter / TableAdapter -- they are too much trouble for real work.

      V 1 Reply Last reply
      0
      • T Trevortni

        I'm trying to edit the CommandText for the Insert Command in a TableAdapter in the Designer in vb.net. Whenever I make changes to the CommandText, Visual Studio (2008) automagically changes the Parameters to a Collection consisting of one Parameter that existed before editing the Command, immersed in a sea of complete garbage Parameters, and then I either have to undo (unless this was the first thing I tried editing, in which case I have to close the Designer to discard changes and reopen it) or manually change ALL the Parameters back to something that isn't complete garbage. Has anybody seen anything like this, or know how to stop Visual Studio from murdering my carefully tended Parameters? Any way to change the CommandText without finding yet another reason to curse the name of M$ would be greatly appreciated.

        A Offline
        A Offline
        Abhishek Sur
        wrote on last edited by
        #3

        Parameters are build based on CommandText. So if you are going to change command text, you would need to change the parameters as well.

        Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.


        Visit My Website-->**

        www.abhisheksur.com

        P T 2 Replies Last reply
        0
        • A Abhishek Sur

          Parameters are build based on CommandText. So if you are going to change command text, you would need to change the parameters as well.

          Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.


          Visit My Website-->**

          www.abhisheksur.com

          P Offline
          P Offline
          PIEBALDconsult
          wrote on last edited by
          #4

          Not always, I can have parameters set up according to the columns of a particular table and then wish to set the command as appropriate for a task and not need to alter the Parameters collection. But to do that I need to roll my own -- which I do.

          1 Reply Last reply
          0
          • T Trevortni

            I'm trying to edit the CommandText for the Insert Command in a TableAdapter in the Designer in vb.net. Whenever I make changes to the CommandText, Visual Studio (2008) automagically changes the Parameters to a Collection consisting of one Parameter that existed before editing the Command, immersed in a sea of complete garbage Parameters, and then I either have to undo (unless this was the first thing I tried editing, in which case I have to close the Designer to discard changes and reopen it) or manually change ALL the Parameters back to something that isn't complete garbage. Has anybody seen anything like this, or know how to stop Visual Studio from murdering my carefully tended Parameters? Any way to change the CommandText without finding yet another reason to curse the name of M$ would be greatly appreciated.

            M Offline
            M Offline
            Mycroft Holmes
            wrote on last edited by
            #5

            There is a reason why you are getting limited help on this subject, very few experienced devs will use the table adapters. They are one of the worst things MS has inflicted on us, they allow a new developer to get data to the UI with almost no knowledge of how it was achieved. Look into buiding or implementing a data access layer DAL. This will give you much greater knowledge and therefore control over your data.

            Never underestimate the power of human stupidity RAH

            T 1 Reply Last reply
            0
            • A Abhishek Sur

              Parameters are build based on CommandText. So if you are going to change command text, you would need to change the parameters as well.

              Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.


              Visit My Website-->**

              www.abhisheksur.com

              T Offline
              T Offline
              Trevortni
              wrote on last edited by
              #6

              Yes, I understand this, and I am quite fine with this. The problem is, VS changes the Parameters for me, instead of giving me the option to specify the Parameters myself.

              P 1 Reply Last reply
              0
              • M Mycroft Holmes

                There is a reason why you are getting limited help on this subject, very few experienced devs will use the table adapters. They are one of the worst things MS has inflicted on us, they allow a new developer to get data to the UI with almost no knowledge of how it was achieved. Look into buiding or implementing a data access layer DAL. This will give you much greater knowledge and therefore control over your data.

                Never underestimate the power of human stupidity RAH

                T Offline
                T Offline
                Trevortni
                wrote on last edited by
                #7

                Mycroft Holmes wrote:

                worst things MS has inflicted on us, they allow a new developer to get data to the UI with almost no knowledge of how it was achieved.

                And this is a bad thing why? Anyway, the problem is not that I don't know what I'm doing. I know exactly what it should look like, and know that if I can get the screen to look like this, it will work as expected. The internals of the Table Adapter are not the problem; the problem is the Designer changing parameters without my permission. If you don't know how to convince the UI to not drop data, man up and confess your ignorance rather than using it as an excuse to make yourself sound like an elitist snob. That does nobody any good, and makes you look stupid. Allow me to demonstrate:

                Bad:

                HAHAHAHA!!!! LOSER!!!! ONLY N000BS USE M$ COMPONENTS!!!! ROLL YOUR OWN N0000B!!!!1111ONEONE

                Good:

                Oooh, sorry, I never use TableAdapters, I've never had anything but problems with them, and in my experience, most people around here feel the same. Have you considered making your own or implementing one from somewhere else? It always seems to work out easier for me in the long run.

                You see the difference? They both offer the same advice, but the second one actually comes across as advice rather than an elitist slam. ---- All ranting aside, I do appreciate your advice, and while it doesn't look like implementing some other solution is an immediately viable solution (I'm not the only person in this code, and the senior programmer who originally implemented this would seem to take offense at the idea that he has no idea what he's doing), I will keep it in mind should I come across database needs more complex than can be solved through whatever it takes to get this UI in line (which looks like my only option might be to let VS destroy my Parameters and then manually rewrite them all.... sigh....)

                M 1 Reply Last reply
                0
                • T Trevortni

                  Mycroft Holmes wrote:

                  worst things MS has inflicted on us, they allow a new developer to get data to the UI with almost no knowledge of how it was achieved.

                  And this is a bad thing why? Anyway, the problem is not that I don't know what I'm doing. I know exactly what it should look like, and know that if I can get the screen to look like this, it will work as expected. The internals of the Table Adapter are not the problem; the problem is the Designer changing parameters without my permission. If you don't know how to convince the UI to not drop data, man up and confess your ignorance rather than using it as an excuse to make yourself sound like an elitist snob. That does nobody any good, and makes you look stupid. Allow me to demonstrate:

                  Bad:

                  HAHAHAHA!!!! LOSER!!!! ONLY N000BS USE M$ COMPONENTS!!!! ROLL YOUR OWN N0000B!!!!1111ONEONE

                  Good:

                  Oooh, sorry, I never use TableAdapters, I've never had anything but problems with them, and in my experience, most people around here feel the same. Have you considered making your own or implementing one from somewhere else? It always seems to work out easier for me in the long run.

                  You see the difference? They both offer the same advice, but the second one actually comes across as advice rather than an elitist slam. ---- All ranting aside, I do appreciate your advice, and while it doesn't look like implementing some other solution is an immediately viable solution (I'm not the only person in this code, and the senior programmer who originally implemented this would seem to take offense at the idea that he has no idea what he's doing), I will keep it in mind should I come across database needs more complex than can be solved through whatever it takes to get this UI in line (which looks like my only option might be to let VS destroy my Parameters and then manually rewrite them all.... sigh....)

                  M Offline
                  M Offline
                  Mycroft Holmes
                  wrote on last edited by
                  #8

                  Trevortni wrote:

                  man up and confess your ignorance rather than using it as an excuse to make yourself sound like an elitist snob.

                  I thought it was rather obvious that I didn't have the answer, the reason I waited to see if somone else had come up with something more constructive.

                  Trevortni wrote:

                  senior programmer who originally implemented this

                  I'm astonished a senior dev would be using table adaptors, I would not allow that on any project I was involved in and would question the devs claim to seniority. Also this probably would have got a better response in the C#/VB forum as it really is the UI code misbehaving. Do take a look at some of the articles here as there are some excellent DALs available in them.

                  Never underestimate the power of human stupidity RAH

                  P 1 Reply Last reply
                  0
                  • T Trevortni

                    Yes, I understand this, and I am quite fine with this. The problem is, VS changes the Parameters for me, instead of giving me the option to specify the Parameters myself.

                    P Offline
                    P Offline
                    PIEBALDconsult
                    wrote on last edited by
                    #9

                    Trevortni wrote:

                    VS changes the Parameters for me

                    No it doesn't; the CommandBuilder does.

                    1 Reply Last reply
                    0
                    • M Mycroft Holmes

                      Trevortni wrote:

                      man up and confess your ignorance rather than using it as an excuse to make yourself sound like an elitist snob.

                      I thought it was rather obvious that I didn't have the answer, the reason I waited to see if somone else had come up with something more constructive.

                      Trevortni wrote:

                      senior programmer who originally implemented this

                      I'm astonished a senior dev would be using table adaptors, I would not allow that on any project I was involved in and would question the devs claim to seniority. Also this probably would have got a better response in the C#/VB forum as it really is the UI code misbehaving. Do take a look at some of the articles here as there are some excellent DALs available in them.

                      Never underestimate the power of human stupidity RAH

                      P Offline
                      P Offline
                      PIEBALDconsult
                      wrote on last edited by
                      #10

                      Mycroft Holmes wrote:

                      it really is the UI code misbehaving

                      I doubt that very much. It's the DataAdapter and CommandBuilder (and probably Clippy) trying to be helpful.

                      M 1 Reply Last reply
                      0
                      • P PIEBALDconsult

                        Mycroft Holmes wrote:

                        it really is the UI code misbehaving

                        I doubt that very much. It's the DataAdapter and CommandBuilder (and probably Clippy) trying to be helpful.

                        M Offline
                        M Offline
                        Mycroft Holmes
                        wrote on last edited by
                        #11

                        PIEBALDconsult wrote:

                        It's the DataAdapter and CommandBuilder

                        Sure but they are in the UI and in C#/VB rather than the database.

                        Never underestimate the power of human stupidity RAH

                        P 1 Reply Last reply
                        0
                        • M Mycroft Holmes

                          PIEBALDconsult wrote:

                          It's the DataAdapter and CommandBuilder

                          Sure but they are in the UI and in C#/VB rather than the database.

                          Never underestimate the power of human stupidity RAH

                          P Offline
                          P Offline
                          PIEBALDconsult
                          wrote on last edited by
                          #12

                          They have nothing to do with the UI; there are no visible parts, they do the same thing when I write a library with a text editor.

                          1 Reply Last reply
                          0
                          • P PIEBALDconsult

                            I expect that's what it's supposed to do. Never use a DataAdapter / TableAdapter -- they are too much trouble for real work.

                            V Offline
                            V Offline
                            Vimalsoft Pty Ltd
                            wrote on last edited by
                            #13

                            That is why i dont use wizards to do my Data Layer

                            Vuyiswa Maseko, Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code. C#/VB.NET/ASP.NET/SQL7/2000/2005/2008 http://www.vuyiswamaseko.com vuyiswa@its.co.za http://www.itsabacus.co.za/itsabacus/

                            P 1 Reply Last reply
                            0
                            • V Vimalsoft Pty Ltd

                              That is why i dont use wizards to do my Data Layer

                              Vuyiswa Maseko, Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code. C#/VB.NET/ASP.NET/SQL7/2000/2005/2008 http://www.vuyiswamaseko.com vuyiswa@its.co.za http://www.itsabacus.co.za/itsabacus/

                              P Offline
                              P Offline
                              PIEBALDconsult
                              wrote on last edited by
                              #14

                              Nor do I. :thumbsup:

                              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