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. Windows Forms
  4. C# code problem

C# code problem

Scheduled Pinned Locked Moved Windows Forms
databasehelpcsharpmysqlsysadmin
8 Posts 5 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.
  • N Offline
    N Offline
    nitish_07
    wrote on last edited by
    #1

    I have a button in my form and on click of that button I am writing this code.... OdbcCommand cmd ; cmd = new OdbcCommand(abc, cn); cmd.CommandType = CommandType.StoredProcedure; cmd.ExecuteNonQuery(); I have made a procedure named abc in database which is returning only one row from login table..So i am just checking that on click of that button my procedure should run but while debugging when i come to cmd.ExecuteQuery() it throws following error.. ERROR [42000] [MySQL][ODBC 5.1 Driver][mysqld-5.0.77-community-nt]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'abc()' at line 1. So plz tell me what would be the problem..

    L 2 Replies Last reply
    0
    • N nitish_07

      I have a button in my form and on click of that button I am writing this code.... OdbcCommand cmd ; cmd = new OdbcCommand(abc, cn); cmd.CommandType = CommandType.StoredProcedure; cmd.ExecuteNonQuery(); I have made a procedure named abc in database which is returning only one row from login table..So i am just checking that on click of that button my procedure should run but while debugging when i come to cmd.ExecuteQuery() it throws following error.. ERROR [42000] [MySQL][ODBC 5.1 Driver][mysqld-5.0.77-community-nt]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'abc()' at line 1. So plz tell me what would be the problem..

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

      Please stop spamming the forums with this same question[^]. You have been given suggestions about resolving this, go and try some of them.

      speaking as ...

      N 1 Reply Last reply
      0
      • L Lost User

        Please stop spamming the forums with this same question[^]. You have been given suggestions about resolving this, go and try some of them.

        speaking as ...

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

        Sir I have tried all the suggestions...and as u said i have posted in mysql but there was no reply..so i posted here...

        L 1 Reply Last reply
        0
        • N nitish_07

          Sir I have tried all the suggestions...and as u said i have posted in mysql but there was no reply..so i posted here...

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

          nitish_07 wrote:

          i have posted in mysql but there was no reply

          Then you need to be more patient, and also read http://www.codeproject.com/Messages/3137519/Forum-Guidelines-PLEASE-READ.aspx[^].

          speaking as ...

          1 Reply Last reply
          0
          • N nitish_07

            I have a button in my form and on click of that button I am writing this code.... OdbcCommand cmd ; cmd = new OdbcCommand(abc, cn); cmd.CommandType = CommandType.StoredProcedure; cmd.ExecuteNonQuery(); I have made a procedure named abc in database which is returning only one row from login table..So i am just checking that on click of that button my procedure should run but while debugging when i come to cmd.ExecuteQuery() it throws following error.. ERROR [42000] [MySQL][ODBC 5.1 Driver][mysqld-5.0.77-community-nt]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'abc()' at line 1. So plz tell me what would be the problem..

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

            nitish_07 wrote:

            cmd = new OdbcCommand(abc, cn);

            Your problem is that you did not read the error message, nor the manual that the error is referring to.

            using (cmd = cn.CreateCommand())
            {
            cmd.CommandText = "EXEC abc()";
            cmd.ExecuteNonQuery(); // this means that there'll be no results
            }

            I don't want to see this question coming back :)

            Bastard Programmer from Hell :suss:

            Richard Andrew x64R M P 3 Replies Last reply
            0
            • L Lost User

              nitish_07 wrote:

              cmd = new OdbcCommand(abc, cn);

              Your problem is that you did not read the error message, nor the manual that the error is referring to.

              using (cmd = cn.CreateCommand())
              {
              cmd.CommandText = "EXEC abc()";
              cmd.ExecuteNonQuery(); // this means that there'll be no results
              }

              I don't want to see this question coming back :)

              Bastard Programmer from Hell :suss:

              Richard Andrew x64R Offline
              Richard Andrew x64R Offline
              Richard Andrew x64
              wrote on last edited by
              #6

              Good eye! :thumbsup:

              The difficult we do right away... ...the impossible takes slightly longer.

              1 Reply Last reply
              0
              • L Lost User

                nitish_07 wrote:

                cmd = new OdbcCommand(abc, cn);

                Your problem is that you did not read the error message, nor the manual that the error is referring to.

                using (cmd = cn.CreateCommand())
                {
                cmd.CommandText = "EXEC abc()";
                cmd.ExecuteNonQuery(); // this means that there'll be no results
                }

                I don't want to see this question coming back :)

                Bastard Programmer from Hell :suss:

                M Offline
                M Offline
                Manfred Rudolf Bihy
                wrote on last edited by
                #7

                There is another faux pas OP committed. Not reading the MSDN documentation on EXEC / EXECUTE diligently:

                MSDN[^] wrote:

                [ { EXEC | EXECUTE } ]
                {
                [ @return_status = ]
                { module_name [ ;number ] | @module_name_var }
                [ [ @parameter = ] { value
                | @variable [ OUTPUT ]
                | [ DEFAULT ]
                }
                ]
                [ ,...n ]
                [ WITH [ ,...n ] ]
                }
                [;]

                Execute a character string
                { EXEC | EXECUTE }
                ( { @string_variable | [ N ]'tsql_string' } [ + ...n ] )
                [ AS { LOGIN | USER } = ' name ' ]
                [;]

                Execute a pass-through command against a linked server
                { EXEC | EXECUTE }
                ( { @string_variable | [ N ] 'command_string [ ? ]' } [ + ...n ]
                [ { , { value | @variable [ OUTPUT ] } } [ ...n ] ]
                )
                [ AS { LOGIN | USER } = ' name ' ]
                [ AT linked_server_name ]
                [;]

                Parenthesis () are only allowed when executing indirectly via a string variable or string literal. Regards, Manfred

                "With sufficient thrust, pigs fly just fine."

                Ross Callon, The Twelve Networking Truths, RFC1925

                "Der Berg ruft!"

                Me, 2012-05-24

                1 Reply Last reply
                0
                • L Lost User

                  nitish_07 wrote:

                  cmd = new OdbcCommand(abc, cn);

                  Your problem is that you did not read the error message, nor the manual that the error is referring to.

                  using (cmd = cn.CreateCommand())
                  {
                  cmd.CommandText = "EXEC abc()";
                  cmd.ExecuteNonQuery(); // this means that there'll be no results
                  }

                  I don't want to see this question coming back :)

                  Bastard Programmer from Hell :suss:

                  P Offline
                  P Offline
                  Pete OHanlon
                  wrote on last edited by
                  #8

                  I pointed this out to him in his original post.

                  *pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

                  "Mind bleach! Send me mind bleach!" - Nagy Vilmos

                  CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

                  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