Dan,
Thanks heaps for your help.
Much appreciated.
Regards
David Huisman
"Dan Guzman" <danguzman@nospam-earthlink.net> wrote in message
news:aLTFc.5144$oD3.4730@newsread1.news.pas.earthl ink.net...[color=blue]
> Much of DMO functionality can be accomplished via directly via SQL. BTW,
> many DMO methods execute SQL Server stored procedures internally but
> undocumented procs shouldn't be called directly by production[/color]
applications.[color=blue]
>
> Below is SQL script that will enumerate SQL Servers. Of course, you'll[/color]
need[color=blue]
> to connect to a SQL Server to execute this so this is a catch-22 situation
> when you need to list servers before connecting. Also, this is intended[/color]
to[color=blue]
> be run only by sysadmin role members.
>
> CREATE TABLE #SqlServers
> (
> SqlServerName nvarchar(255)
> )
>
> INSERT #SqlServers
> EXEC master..xp_cmdshell 'OSQL -L'
>
> SELECT
> CASE LTRIM(SqlServerName)
> WHEN '(local)' THEN @@SERVERNAME
> ELSE LTRIM(SqlServerName) END AS SqlServerName
> FROM #SqlServers
> WHERE SqlServerName <> 'NULL' AND
> SqlServerName <> 'Servers:'
>
> DROP TABLE #SqlServers
> GO
>
> You can find code examples to list SQL Servers without DMO at the links
> below. These are written in C++ but it shouldn't be difficult to use the
> same API calls in VB.NET.
>
> ODBC SQLBrowseConnect:
http://www.sqldev.net/misc/ListSQLSvr.htm
> LAN Manager NetServerEnum():
http://www.sqldev.net/misc/EnumSQLSvr.htm
>
> One method to list databases is Transact-SQL:
>
> SELECT CATALOG_NAME
> FROM INFORMATION_SCHEMA.SCHEMATA
> ORDER BY CATALOG_NAME
> GO
>
> To list files for the current database:
>
> SELECT filename
> FROM sysfiles
> GO
>
> --
> Hope this helps.
>
> Dan Guzman
> SQL Server MVP
>
> "David" <david@orbitcoms.com> wrote in message
> news:seMFc.77482$sj4.56090@news-server.bigpond.net.au...[color=green]
> > Dan,
> >
> > Can I use a similar method as shown in your code to List the available
> > servers and databases so that I do not require DBO at all ? This will[/color]
> enable[color=green]
> > me to send the users updates of the programs that may have additional
> > databases added. The user can select a server if they already have a non
> > MSDE server installed. Also, the code can scan the server db files list[/color][/color]
to[color=blue][color=green]
> > ensure it only attaches files not already attached.
> >[/color]
>
>[/color]