473,473 Members | 1,814 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Checking is SQL Service has started

Hi,

Is it posssible to check if the SQL service is running. I have some code
accessing a SQL Database, but I get a nasty message if I forget to start SQL
Service.

--
Steven
www.stevenblair.com
Nov 15 '05 #1
3 1563
If your code is running from the Server you can use the Process class to
verify that it's running. However, you may want to wrap the Connection.Open
in a Try/Catch block b/c this will fail if the service isn't running and
opening connections is a 'risky' operation.

HTH,

Bill
"Steven Blair" <st**********@btinternet.com> wrote in message
news:bt**********@hercules.btinternet.com...
Hi,

Is it posssible to check if the SQL service is running. I have some code
accessing a SQL Database, but I get a nasty message if I forget to start SQL Service.

--
Steven
www.stevenblair.com

Nov 15 '05 #2
You can connect to sql server with socket and check if your server can accept incoming connections.

Here is code example:

Socket m_socClient = new Socket(AddressFamily.InterNetwork,SocketType.Strea m,ProtocolType.Tcp);
try
{
System.Net.IPAddress ipAdd = System.Net.IPAddress.Parse("SQL server IP Address");
System.Net.IPEndPoint remoteEP = new System.Net.IPEndPoint (ipAdd,1433);
m_socClient.Connect (remoteEP);
Console.WriteLine ("Your SQL is ronnung");
m_socClient.Close();
}
catch(SocketException se)
{
Console.WriteLine ("Your SQL seems not to be running");
}
Nov 15 '05 #3
You can connect to sql server with socket and check if your server can accept incoming connections

Here is code example

Socket m_socClient = new Socket(AddressFamily.InterNetwork,SocketType.Strea m,ProtocolType.Tcp);
try

System.Net.IPAddress ipAdd = System.Net.IPAddress.Parse("SQL server IP Address")
System.Net.IPEndPoint remoteEP = new System.Net.IPEndPoint (ipAdd,1433)
m_socClient.Connect (remoteEP);
Console.WriteLine ("Your SQL is ronnung")
m_socClient.Close()

catch(SocketException se
{
Console.WriteLine ("Your SQL seems not to be running")
Nov 15 '05 #4

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

Similar topics

2
by: jmlynn | last post by:
Help! I installed MySQL 4.0.20C and it works if I started it with mysqld --console However, if I do the following: mysqld --install net start MySQL
2
by: Mike Parris | last post by:
Is there a trick to getting a Windows Service to start before a user has logged on to a machine? Using VS.net 2003 on a Windows 2000 machine, I have built a Windows service using vb.net . I have...
7
by: Ross Presser | last post by:
OK, I've been researching this problem and can't find a definitive answer yet. The situation is one that seems to have come up a few times to different folks. I am writing an application that...
15
by: Chakkaradeep | last post by:
Hi all, i have written a Service,now i want to execute another application (for eg;calc.exe) in the service....how will i perform it??... i tried using this.... /**************Executing a...
1
by: benmorganpowell | last post by:
I have a small windows service which connects to a POP3 server at defined intervals, scans the available messages, extracts the required information and inserts the data into a SQL database. I am...
4
by: Simon Verona | last post by:
My software relies on a third party data provider to a propretary database. In turn the third party database relies on a Windows Service that runs on the server to supply the data... The problem...
4
by: kkt49 | last post by:
# vim: et sw=4 ts=8 sts from wxPython.wx import * import sys, os, time import pywintypes import win32serviceutil import win32service import win32event import win32process
2
by: TonyJ | last post by:
Hello!! Below I have written the main method, the C-tor and the OnStart. Who is calling OnStart? It must be the operating system that calls it after the C-tor has finished 1. Main is always...
0
by: s.kapitza | last post by:
Hi, try M$S servicebug 3 regards s.kapitza alghaden@alumni.fdu.edu (Ahmad) wrote in message news:<4a75f4b7.0308080649.49105373@posting.google.com>...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
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
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.