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. C#
  4. How to send parameter to another program?

How to send parameter to another program?

Scheduled Pinned Locked Moved C#
databasecsharpsql-serversysadmintools
7 Posts 6 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.
  • A Offline
    A Offline
    Affan Toor
    wrote on last edited by
    #1

    Hi, hope every one is doing fine. i am developing application in C# 2005, my requirement is to call the exe of SQL Server 2000 Query Analyzer using code, which i did by using: Process.Start("C:\\Program Files\\Microsoft SQL Server\\80\\Tools\\Binn\\isqlw.exe"); it is working fine, now i want that when user opens the SQL Server query analyzer it automatically open a specific database. is it possible? can i send database name as parameter? or there is any other way to do it? Any kind of help is appreciated, thanks in advance Regards, Affan Ahmad Toor .................. QUAIDIAN FOR ONCE, QUAIDIAN FOR EVER!

    A G J 3 Replies Last reply
    0
    • A Affan Toor

      Hi, hope every one is doing fine. i am developing application in C# 2005, my requirement is to call the exe of SQL Server 2000 Query Analyzer using code, which i did by using: Process.Start("C:\\Program Files\\Microsoft SQL Server\\80\\Tools\\Binn\\isqlw.exe"); it is working fine, now i want that when user opens the SQL Server query analyzer it automatically open a specific database. is it possible? can i send database name as parameter? or there is any other way to do it? Any kind of help is appreciated, thanks in advance Regards, Affan Ahmad Toor .................. QUAIDIAN FOR ONCE, QUAIDIAN FOR EVER!

      A Offline
      A Offline
      Anthony Mushrow
      wrote on last edited by
      #2

      Well, you can pass parameters like this: Process.Start("Application Path", "Parameters"); ... i think. If it actually takes a parameter, i don't know. Just pass the path to the file, and see if it works.

      My current favourite word is: Nipple!

      -SK Genius

      1 Reply Last reply
      0
      • A Affan Toor

        Hi, hope every one is doing fine. i am developing application in C# 2005, my requirement is to call the exe of SQL Server 2000 Query Analyzer using code, which i did by using: Process.Start("C:\\Program Files\\Microsoft SQL Server\\80\\Tools\\Binn\\isqlw.exe"); it is working fine, now i want that when user opens the SQL Server query analyzer it automatically open a specific database. is it possible? can i send database name as parameter? or there is any other way to do it? Any kind of help is appreciated, thanks in advance Regards, Affan Ahmad Toor .................. QUAIDIAN FOR ONCE, QUAIDIAN FOR EVER!

        G Offline
        G Offline
        Giorgi Dalakishvili
        wrote on last edited by
        #3

        If the process you are starting supports command-line parameters, then you can send them by using on of the overload of Process.Start method

        #region signature my articles #endregion

        1 Reply Last reply
        0
        • A Affan Toor

          Hi, hope every one is doing fine. i am developing application in C# 2005, my requirement is to call the exe of SQL Server 2000 Query Analyzer using code, which i did by using: Process.Start("C:\\Program Files\\Microsoft SQL Server\\80\\Tools\\Binn\\isqlw.exe"); it is working fine, now i want that when user opens the SQL Server query analyzer it automatically open a specific database. is it possible? can i send database name as parameter? or there is any other way to do it? Any kind of help is appreciated, thanks in advance Regards, Affan Ahmad Toor .................. QUAIDIAN FOR ONCE, QUAIDIAN FOR EVER!

          J Offline
          J Offline
          Justin Perez
          wrote on last edited by
          #4

          You'll have to find out if SQL Server can take a paramater at run-time, and do something with it. I'd assume that it can, but if it doesn't you can't do it, obviously. You'll have to find the paramater switches, such as "netstat -o" or something like that. If you find whether or not they are supported, and find the paramater switch you want to use. Something like this would do what you want:

            Process cmdLineProcess = new Process();
          
            cmdLineProcess.StartInfo.FileName = strFile;
            cmdLineProcess.StartInfo.Arguments = strArgs;
            cmdLineProcess.StartInfo.UseShellExecute = false;
            cmdLineProcess.StartInfo.CreateNoWindow = true;
            cmdLineProcess.StartInfo.RedirectStandardOutput = true;
            cmdLineProcess.StartInfo.RedirectStandardError = true;
          
            cmdLineProcess.Start()
          

          Let us know what you find out, I'd be interested to know if SQL supports that. I'm guessing it does, so good luck. Post a link to what you find! :)

          I'm going to become rich when I create a device that allows me to punch people in the face over the internet. "If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer

          P 1 Reply Last reply
          0
          • J Justin Perez

            You'll have to find out if SQL Server can take a paramater at run-time, and do something with it. I'd assume that it can, but if it doesn't you can't do it, obviously. You'll have to find the paramater switches, such as "netstat -o" or something like that. If you find whether or not they are supported, and find the paramater switch you want to use. Something like this would do what you want:

              Process cmdLineProcess = new Process();
            
              cmdLineProcess.StartInfo.FileName = strFile;
              cmdLineProcess.StartInfo.Arguments = strArgs;
              cmdLineProcess.StartInfo.UseShellExecute = false;
              cmdLineProcess.StartInfo.CreateNoWindow = true;
              cmdLineProcess.StartInfo.RedirectStandardOutput = true;
              cmdLineProcess.StartInfo.RedirectStandardError = true;
            
              cmdLineProcess.Start()
            

            Let us know what you find out, I'd be interested to know if SQL supports that. I'm guessing it does, so good luck. Post a link to what you find! :)

            I'm going to become rich when I create a device that allows me to punch people in the face over the internet. "If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer

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

            It seems that somebody doesn't like you. You've got a 1 vote fanboy.

            Deja View - the feeling that you've seen this post before.

            My blog | My articles

            J K 2 Replies Last reply
            0
            • P Pete OHanlon

              It seems that somebody doesn't like you. You've got a 1 vote fanboy.

              Deja View - the feeling that you've seen this post before.

              My blog | My articles

              J Offline
              J Offline
              Justin Perez
              wrote on last edited by
              #6

              :-\ I couldn't possible imagine why anyone wouldn't like me. :laugh: :laugh:

              I'm going to become rich when I create a device that allows me to punch people in the face over the internet. "If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer

              1 Reply Last reply
              0
              • P Pete OHanlon

                It seems that somebody doesn't like you. You've got a 1 vote fanboy.

                Deja View - the feeling that you've seen this post before.

                My blog | My articles

                K Offline
                K Offline
                KarstenK
                wrote on last edited by
                #7

                Or somebody thinks that "1" is the best. So were my rarely best school notes. :-O

                Greetings from Germany

                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