0

I have a query I am creating a Window App in vb.net (4.0) in which I have to use multiple databases although all databases are same with same db structure & stored procedures,just names are different. In the very starting of application, I need to give a option to the user that these are available db & user will select which one to connect & use.

So is it possible to detect how many db are available in the SQL Server through vb.net & how can achieve this (to provide options to the user) ? What would be the best approach?

Thanks

1

3 Answers 3

1

It dependso n permissions.

Basically you can always conect to the server and ask the server. All metadaa is available in the system management database and you can submit sql there to ask for waht databases exist.

Get list of databases from SQL Server

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

Comments

1

The sql server knows how many databases are installed, you can just query it. Your login needs to have permission to make the query, so you probably will want to use different connection strings for this query vs others.

Also, given the right permissions you can discover not only if the database exist, but whether it is structually acceptable

Comments

0

sure, you just have to call any procedure on the server that can list the DB's for you. Try:

EXEC sp_databases
EXEC sp_helpdb

there is also an 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.