hi,
i'm working on a windows service in vb.net which will be started
automatically. but sometimes, on startup, it will show this error --
ERROR [08001] [Microsoft][ODBC SQL Server Driver][Shared Memory]SQL
Server does not exist or access denied.
I think this is because, my service uses an sql server connection, but
sql server starts only after my service.
plz help me out to check whether the sql server is up in vb.net code so
that if it is not started, v can wait for it to start.
thanx
vipinPing to the server.
CREATE TABLE #t_ip (ip varchar(255))
DECLARE @.PingSql varchar(1000)
SELECT @.PingSql = 'ping ' + '00.00.0.0'
INSERT INTO #t_ip EXEC master.dbo.xp_cmdshell @.PingSql
SELECT * FROM #t_ip
IF EXISTS (SELECT TOP 2 * FROM #t_ip WHERE IP = 'Request timed out' )
BEGIN
DROP TABLE #t_ip
RETURN
END
DROP TABLE #t_ip
<vipinhari@.gmail.com> wrote in message
news:1142402449.177773.136960@.j52g2000cwj.googlegroups.com...
> hi,
> i'm working on a windows service in vb.net which will be started
> automatically. but sometimes, on startup, it will show this error --
> ERROR [08001] [Microsoft][ODBC SQL Server Driver][Shared Memory]SQL
> Server does not exist or access denied.
> I think this is because, my service uses an sql server connection, but
> sql server starts only after my service.
> plz help me out to check whether the sql server is up in vb.net code so
> that if it is not started, v can wait for it to start.
> thanx
> vipin
>|||Uri,
That's fine but your snippet only check whether such workstation/server is
up, nothing about sql server/agent services.
--
current location: alicante (es)
"Uri Dimant" wrote:
> Ping to the server.
> CREATE TABLE #t_ip (ip varchar(255))
> DECLARE @.PingSql varchar(1000)
> SELECT @.PingSql = 'ping ' + '00.00.0.0'
> INSERT INTO #t_ip EXEC master.dbo.xp_cmdshell @.PingSql
> SELECT * FROM #t_ip
> IF EXISTS (SELECT TOP 2 * FROM #t_ip WHERE IP = 'Request timed out' )
> BEGIN
> DROP TABLE #t_ip
> RETURN
> END
> DROP TABLE #t_ip
>
> <vipinhari@.gmail.com> wrote in message
> news:1142402449.177773.136960@.j52g2000cwj.googlegroups.com...
>
>|||Hi,
if you don=B4t wanna use SMO to check this, simply build a snippet of
code connection to the server and encapsulate this with a try catch
block.
HTH, Jens Suessmeyer.
http://www.sqlserver2005.de
--|||Using the .Status property of the SQLDMO.SQLServer object, you can test the
status of a SQL Server. Also of interest are the .Start, .Pause, .Continue,
and .Stop method calls.
http://www.devx.com/vb2themax/Tip/18459
Discuss with the DBA or network admin why the server would occasionally not
be running when needed.
<vipinhari@.gmail.com> wrote in message
news:1142402449.177773.136960@.j52g2000cwj.googlegroups.com...
> hi,
> i'm working on a windows service in vb.net which will be started
> automatically. but sometimes, on startup, it will show this error --
> ERROR [08001] [Microsoft][ODBC SQL Server Driver][Shared Memory]SQL
> Server does not exist or access denied.
> I think this is because, my service uses an sql server connection, but
> sql server starts only after my service.
> plz help me out to check whether the sql server is up in vb.net code so
> that if it is not started, v can wait for it to start.
> thanx
> vipin
>
No comments:
Post a Comment