Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / March 2008

Tip: Looking for answers? Try searching our database.

How to detect SQLServer 2005 ?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ad - 16 Mar 2008 05:25 GMT
How can I detect if my computer have installed SQLServer 2005 or SQLServer
2005 Express with program like c# or VB.NNET?
GuangXiN - 16 Mar 2008 07:26 GMT
using System.ServiceProcess;
private void button1_Click(object sender, System.EventArgs e)
 {
  if(ExistSqlServerService())
  {
   MessageBox.Show("This computer has installed SQLServer");
  }
  else
  {
   MessageBox.Show("This computer hasn't installed SQLServer");
  }

"ad" <flying@wfes.tcc.edu.tw>
2306S3xhIHA.1132@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?
Duy Lam - 16 Mar 2008 11:24 GMT
> using System.ServiceProcess;
> private void button1_Click(object sender, System.EventArgs e)
[quoted text clipped - 12 lines]
>> How can I detect if my computer have installed SQLServer 2005 or SQLServer
>> 2005 Express with program like c# or VB.NNET?

where is ExistSqlServerService() method ?

Signature

Thanks,
Duy Lam Phuong

GuangXiN - 16 Mar 2008 12:17 GMT
I miss some code

public static bool ExistSqlServerService() {
   bool flag = false;
   ServiceController[] services = ServiceController.GetServices();
   for(int i = 0; i < services.Length; i++) {
       if(services[i].DisplayName.ToString().Equals("MSSQLSERVER") {
           flag = true;
           break;
       }
   }
   return flag;
}
Arne Vajhøj - 17 Mar 2008 02:56 GMT
> I miss some code
>
[quoted text clipped - 9 lines]
>     return flag;
> }

The service can have different names.

Arne
Duy Lam - 16 Mar 2008 11:29 GMT
> 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(@"select @@VERION");
IDataReader drd = cmd.ExecuteReader();
drd.Read();
string version = drd.GetString(0);
// find version in string
if( version.Contain("Express") )
{
    // Oh, we are in Express version
}

Signature

Thanks,
Duy Lam Phuong

Duy Lam - 16 Mar 2008 11:30 GMT
> 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:
http://sqlserver2000.databases.aspfaq.com/how-do-i-know-which-version-of-sql-ser
ver-i-m-running.html


Signature

Thanks,
Duy Lam Phuong


Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.