473,406 Members | 2,345 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

How to detect SQLServer 2005 ?

ad

How can I detect if my computer have installed SQLServer 2005 or SQLServer
2005 Express with program like c# or VB.NNET?
Mar 16 '08 #1
6 1879
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" <fl****@wfes.tcc.edu.tw>
23**************@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?

Mar 16 '08 #2
GuangXiN wrote:
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" <fl****@wfes.tcc.edu.tw>
23**************@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 ExistSqlServerService() method ?

--
Thanks,
Duy Lam Phuong
Mar 16 '08 #3
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(@"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
}

--
Thanks,
Duy Lam Phuong
Mar 16 '08 #4
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:
http://sqlserver2000.databases.aspfa...m-running.html

--
Thanks,
Duy Lam Phuong
Mar 16 '08 #5
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;
}
Mar 16 '08 #6
GuangXiN wrote:
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;
}
The service can have different names.

Arne
Mar 17 '08 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Roy Gourgi | last post by:
Hi, I need to store and retrieve information from a database. It looks as though there is a lot more support for SQLServer than there is for Access, correct me if I am wrong. What do I have...
5
by: AAA | last post by:
Hi, How can I detect all SQL Server, and show all server name in a combo box in vb.net ? Thank you very much Regards
0
by: Ron | last post by:
Hi there My company is developing a web based document archival and retrieval system, using ASP.NET, c# and sqlserver 2000. This development is in testing at present and all looks promising. ...
3
by: Dan Sikorsky | last post by:
Can I use SQLServer 2000 with ASP.NET 2.0 instead of SQLServer 2005, and use the .Net 2.0 Membership functionality? I've setup my Login page, controls, etc., and now it's time to use the Web...
2
by: C.O.Jones | last post by:
I've previously used version 7 and 2000. I've recently started to learn ASP.net. I've installed Visual Web Developer 2005 Express and this includes SQLServer 2005 in the installation. The task...
2
by: Jenniflower | last post by:
Hi Gurus, Our system is using SqlServer 2005 on XP.( On my machine,only this application access SQLServer.) The sqlserver memory is configured to 128MB (Min)~512 MB(Max) After our system get...
2
by: =?Utf-8?B?SmVmZnJleQ==?= | last post by:
I have some old ASP programs w/ SQLserver 2000 databases. Now I am developing ASP.NET projects using VB 2005 and SQLserver 2005. What are the best procedures to develop and test the ASP.NET...
0
by: seanbrasher | last post by:
I have a web application that uses the Microsoft.SqlServer.Management.Smo namespace objects to do some things with SQL Server. On my box I have the client for SQL 2005, but the test database that...
2
by: yaddesh | last post by:
how can i detect installed sqlserver(s) using VB6
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.