Wrox Programmer Forums
|
Pro VB Databases Advanced-level VB coding questions specific to using VB with databases. Beginning-level questions or issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 8th, 2003, 03:47 PM
Registered User
 
Join Date: Oct 2003
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default netsvc

Hello all

I've been trying to write a script that will check mssqlserver status. I can do it from the command line using netsvc but I having trouble placing it in VB or ASP so I can capture the output text. If anybody knows of any solutions, I'm open

Thanks
EM
 
Old October 10th, 2003, 04:43 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

Take a look at the Windows Scripting Host objects, in particular the WScript.Shell object and its Exec method. When you use the Exec method to run a program, it returns a WshScriptExec object which provides access to stdout, which you can use to capture the netsvc output.

You need to set a ref to 'Windows Script Host Object Model' in your VB project.

hth
Phil
 
Old October 10th, 2003, 07:23 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 839
Thanks: 0
Thanked 1 Time in 1 Post
Default

As an alternative to screen scraping the output of a command line utility to get the information you are looking for, you might also want to take a look at SQL-DMO (data management objects). This is a set of objects that comes with SQL Server that you can use to inspect (and modify) just about any operational aspect of a SQL Server instance.

See BOL index for SQL-DMO.

Jeff Mason
Custom Apps, Inc.
www.custom-apps.com
 
Old October 10th, 2003, 10:56 AM
Registered User
 
Join Date: Oct 2003
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Jeff

Thanks for the DMO info. I will look into it and see if I can use it. Originally I tried to call netsvc from the xp_cmdshell which worked fine for local server but was giving a access violation on remote servers. The problem had to do with authentication for SQL server.









Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.