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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. how execute multi SQL command (C# - ADO.NET)

how execute multi SQL command (C# - ADO.NET)

Scheduled Pinned Locked Moved C#
csharpdatabasehelp
3 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.
  • Z Offline
    Z Offline
    zeroonea
    wrote on last edited by
    #1

    i use [code] string strQuery = "USE HMDTest" + " \nGO" + " \nsp_addrole 'HMEmpManager'" + " \nGO" + " \nsp_addrole 'HMEmpViewer'"; SqlCommand sqlCom = new SqlCommand(strQuery, sqlCon); sqlCom.ExecuteNonQuery(); [/code] but it throw a exception with message: "incorrect syntax near 'GO'...", i need help, thanks.

    V J 2 Replies Last reply
    0
    • Z zeroonea

      i use [code] string strQuery = "USE HMDTest" + " \nGO" + " \nsp_addrole 'HMEmpManager'" + " \nGO" + " \nsp_addrole 'HMEmpViewer'"; SqlCommand sqlCom = new SqlCommand(strQuery, sqlCon); sqlCom.ExecuteNonQuery(); [/code] but it throw a exception with message: "incorrect syntax near 'GO'...", i need help, thanks.

      V Offline
      V Offline
      Vikram A Punathambekar
      wrote on last edited by
      #2

      The three queries are separate, so you must execute them with three statements.

      Cheers, Vikram.


      "But nowadays, it means nothing. Features are never frozen, development keeps happening, bugs never get fixed, and documentation is something you might find on wikipedia." - Marc Clifton on betas.

      Join the CP group at NationStates. Password: byalmightybob

      1 Reply Last reply
      0
      • Z zeroonea

        i use [code] string strQuery = "USE HMDTest" + " \nGO" + " \nsp_addrole 'HMEmpManager'" + " \nGO" + " \nsp_addrole 'HMEmpViewer'"; SqlCommand sqlCom = new SqlCommand(strQuery, sqlCon); sqlCom.ExecuteNonQuery(); [/code] but it throw a exception with message: "incorrect syntax near 'GO'...", i need help, thanks.

        J Offline
        J Offline
        Jaiprakash M Bankolli
        wrote on last edited by
        #3

        I would suggest that write a SP and call that from Application .... here it will take two parameter and

        Regards, Jaiprakash M Bankolli jaiprakash.bankolli@gmail.com Blog: http://jaiprakash.blog.com/ Suggestions: http://jaitoimprove.blog.com/

        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