How to detect SQLServer 2005 ?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ad

    How to detect SQLServer 2005 ?


    How can I detect if my computer have installed SQLServer 2005 or SQLServer
    2005 Express with program like c# or VB.NNET?


  • GuangXiN

    #2
    Re: How to detect SQLServer 2005 ?

    using System.ServiceP rocess;
    private void button1_Click(o bject sender, System.EventArg s e)
    {
    if(ExistSqlServ erService())
    {
    MessageBox.Show ("This computer has installed SQLServer");
    }
    else
    {
    MessageBox.Show ("This computer hasn't installed SQLServer");
    }

    "ad" <flying@wfes.tc c.edu.tw>
    2306S3xhIHA.113 2@TK2MSFTNGP06. phx.gbl...
    >
    How can I detect if my computer have installed SQLServer 2005 or SQLServer
    2005 Express with program like c# or VB.NNET?
    >

    Comment

    • Duy Lam

      #3
      Re: How to detect SQLServer 2005 ?

      GuangXiN wrote:
      using System.ServiceP rocess;
      private void button1_Click(o bject sender, System.EventArg s e)
      {
      if(ExistSqlServ erService())
      {
      MessageBox.Show ("This computer has installed SQLServer");
      }
      else
      {
      MessageBox.Show ("This computer hasn't installed SQLServer");
      }
      >
      "ad" <flying@wfes.tc c.edu.tw>
      2306S3xhIHA.113 2@TK2MSFTNGP06. phx.gbl...
      >How can I detect if my computer have installed SQLServer 2005 or SQLServer
      >2005 Express with program like c# or VB.NNET?
      >>
      >
      >

      where is ExistSqlServerS ervice() method ?

      --
      Thanks,
      Duy Lam Phuong

      Comment

      • Duy Lam

        #4
        Re: How to detect SQLServer 2005 ?

        ad wrote:
        How can I detect if my computer have installed SQLServer 2005 or SQLServer
        2005 Express with program like c# or VB.NNET?
        >
        >

        Just execute a simple sql command to get it.

        SqlCommand cmd = new SqlCommand(@"se lect @@VERION");
        IDataReader drd = cmd.ExecuteRead er();
        drd.Read();
        string version = drd.GetString(0 );
        // find version in string
        if( version.Contain ("Express") )
        {
        // Oh, we are in Express version
        }

        --
        Thanks,
        Duy Lam Phuong

        Comment

        • Duy Lam

          #5
          Re: How to detect SQLServer 2005 ?

          ad wrote:
          How can I detect if my computer have installed SQLServer 2005 or SQLServer
          2005 Express with program like c# or VB.NNET?
          >
          >
          By the way, refer this link:


          --
          Thanks,
          Duy Lam Phuong

          Comment

          • GuangXiN

            #6
            Re: How to detect SQLServer 2005 ?

            I miss some code

            public static bool ExistSqlServerS ervice() {
            bool flag = false;
            ServiceControll er[] services = ServiceControll er.GetServices( );
            for(int i = 0; i < services.Length ; i++) {
            if(services[i].DisplayName.To String().Equals ("MSSQLSERVE R") {
            flag = true;
            break;
            }
            }
            return flag;
            }


            Comment

            • =?ISO-8859-1?Q?Arne_Vajh=F8j?=

              #7
              Re: How to detect SQLServer 2005 ?

              GuangXiN wrote:
              I miss some code
              >
              public static bool ExistSqlServerS ervice() {
              bool flag = false;
              ServiceControll er[] services = ServiceControll er.GetServices( );
              for(int i = 0; i < services.Length ; i++) {
              if(services[i].DisplayName.To String().Equals ("MSSQLSERVE R") {
              flag = true;
              break;
              }
              }
              return flag;
              }
              The service can have different names.

              Arne

              Comment

              Working...