Sure. All you need is to create a connection to the sqlserver and execute
this t-sql.
SELECT CATALOG_NAME
FROM INFORMATION_SCHEMA.SCHEMATA
WHERE has_dbaccess(CATALOG_NAME) = 1
I would highly recommend using this instead of hitting the system table
(sysdatabases) directly. This statement would do 3 things for you.
1. It takes care of security issue - it only returns the name of the
database that the user has access to.
2. It's ANSI compliant.
3. It will work in the next version of sqlserver.
--
-oj
"Matthew Smith" <ma*****@macxxx.com> wrote in message
news:ma***************************@msnews.microsof t.com...
Is it possible to get a list of SQL-Server databases if I know the
server, using C#? I want to provide a drop-down list of them.
Or is there a mechanism for selecting a database?