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. [Message Deleted]

[Message Deleted]

Scheduled Pinned Locked Moved Database
6 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.
  • T Offline
    T Offline
    TheMandolinMan
    wrote on last edited by
    #1

    [Message Deleted]

    W 1 Reply Last reply
    0
    • T TheMandolinMan

      [Message Deleted]

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

      Could you clarify these: - what is the type of cmd - which class is giving the exception - what method are you using when exception is given

      M T 2 Replies Last reply
      0
      • W Wendelius

        Could you clarify these: - what is the type of cmd - which class is giving the exception - what method are you using when exception is given

        M Offline
        M Offline
        Muammar
        wrote on last edited by
        #3

        You scared him out to delete his post! :laugh:


        All generalizations are wrong, including this one! (\ /) (O.o) (><)

        W 1 Reply Last reply
        0
        • M Muammar

          You scared him out to delete his post! :laugh:


          All generalizations are wrong, including this one! (\ /) (O.o) (><)

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

          Hopefully not. At least I had good intentions :)

          1 Reply Last reply
          0
          • W Wendelius

            Could you clarify these: - what is the type of cmd - which class is giving the exception - what method are you using when exception is given

            T Offline
            T Offline
            TheMandolinMan
            wrote on last edited by
            #5

            I figured out my own problem just after posting the message. It was a subtle syntactical error. Nonetheless, I have spent many days trying to debug datatype errors, in which using cmd.Parameters.AddWithValue(...) couldn't seem to get the type right. Finally I began adding the parameters first, with the type specified using cmd.Parameters.Add(..., type) and then adding the value to the parameter. So far this has eliminated the frustrations of my commands not working. However, the jury is still out for me as to whether using parameters is THAT much more convenient or less work that concatenating values into a string. I have a pretty good system worked out where I separate each concatenated value on a separate line my code (for readability) and use a quote(arg) function and formatDate(arg) function for convenience. Public Function quote(arg as String) as String Return chr(34) + arg + chr(34) End Function You get the idea. I find it simpler to debug a query in which I can see all the values by simply printing the string to the debug window, rather than iterating through the parameters collection manually in the immediate window.

            W 1 Reply Last reply
            0
            • T TheMandolinMan

              I figured out my own problem just after posting the message. It was a subtle syntactical error. Nonetheless, I have spent many days trying to debug datatype errors, in which using cmd.Parameters.AddWithValue(...) couldn't seem to get the type right. Finally I began adding the parameters first, with the type specified using cmd.Parameters.Add(..., type) and then adding the value to the parameter. So far this has eliminated the frustrations of my commands not working. However, the jury is still out for me as to whether using parameters is THAT much more convenient or less work that concatenating values into a string. I have a pretty good system worked out where I separate each concatenated value on a separate line my code (for readability) and use a quote(arg) function and formatDate(arg) function for convenience. Public Function quote(arg as String) as String Return chr(34) + arg + chr(34) End Function You get the idea. I find it simpler to debug a query in which I can see all the values by simply printing the string to the debug window, rather than iterating through the parameters collection manually in the immediate window.

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

              Good to hear you got it solved. I see your point, but I believe that parameters benefit you in many ways so I encourage you to use them. One idea that may come handy: Derive your own class from OleDbCommand and use that for database operations. If you need to see the statement and the values for parameters, create a helper method in derived class (of course you can separate this to a helper class). In that method list all the info you need to the output window. Something like:

              public void WhatsInside() {
              Debug.WriteLine(this.CommandText);
              foreach (OleDbParameter param in this.Parameters) {
              Debug.WriteLine(param.DbType + param.value + ...);
              }
              other possible info...
              }

              Added: This method can be called from immediate window while debugging so calls to it doesn't have to exist in code. Also this should be included only in debug builds. Mika

              modified on Wednesday, September 10, 2008 4:41 PM

              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