[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 224
  • Last Modified:

Check if Sql Server exist

Hi ,
i'm an access programmer
how i could check MSDE is installed and sql sever exist

every suggestion will be appriciated
0
ppk54ir
Asked:
ppk54ir
  • 3
  • 2
2 Solutions
 
IceColdasCommented:
oh, simply put the connection code in a try catch
so u dont need to search for further ways to see if the database exists
try {
        //connect to data base
}
catch (Exception exc)
{
   ShowMessage(exc.Message)
}
0
 
SpansuleCommented:
It kind of depends on what you're up to, and what language you're using. Here's a snippet of C# code that will retrieve a list of all the SQL Servers available for connection:

// This part retrieves a list of all of the available SQL Servers that can be connected to
SQLDMO.Application sql = new SQLDMO.ApplicationClass();
try
{
      SQLDMO.NameList servers = sql.ListAvailableSQLServers();
      IEnumerator ServerEnumerator = servers.GetEnumerator();
      while (ServerEnumerator.MoveNext())
      {
            // Do stuff with ServerEnumerator.Current;
      }
}
finally
{
      System.Runtime.InteropServices.Marshal.ReleaseComObject(sql);
      sql = null;
}

Otherwise you can use the registry to find out what versions of SQL Server are installed. Try the following key:

HKLM\SOFTWARE\Microsoft\MSSQLServer\MSSQLServer\CurrentVersion\CurrentVersion

This post lists some other keys to check for different versions of SQL Server: http://www.dotnet247.com/247reference/msgs/55/277144.aspx

You can also identify which MSI was used for installation: http://support.microsoft.com/?kbid=311762

0
 
SpansuleCommented:
I just noticed that he said he was an Access programmer. My comment probably didn't make too much sense in that context then.

I don't have any issues with the topic being closed.
0
 
IceColdasCommented:
Actually this is exactly what he said :
Hi ,i'm an access programmer
how i could check MSDE is installed and ### sql ### sever exist
Probably got his answer and accepted none
0
 
SpansuleCommented:
LOL maybe I read it right the first time.

In that case I think my answer was pretty good. :)
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now