3

From this: Enumerate all running databases

One can list the servers on the network, but once one selects one of those servers, how does one then list the DB's in that server, by using a similar method as above?

Thanks!

2 Answers 2

1

You can use SQL Management Objects (SMO). First, you'd use the SmoApplication class and one of its EnumAvailableSqlServers methods to find the server.

Once you've found the server you want, you'd create a Server instance, and then use its Databases property.

Sign up to request clarification or add additional context in comments.

1 Comment

Oooh, I like this one even better :)
1

Most interactions with a database server eventually translate to SQL. Even if they look like some other API in a higher level. Look for the SQL to do this and just call it from C#

UPDATE: From here

----SQL SERVER 2005 System Procedures
EXEC sp_databases
EXEC sp_helpdb
----SQL 2000 Method still works in SQL Server 2005
SELECT name
FROM sys.databases
SELECT name
FROM sys.sysdatabases
----SQL SERVER Un-Documented Procedure
EXEC sp_msForEachDB 'PRINT ''?'''

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.