i want to create a dropdownlist and when i click the dropdownlist, then it should show the all databases which is present in SQLserver. (now i m using SQLSERVER 2005 and Microsoft VISUAL STUDIO 2005) can anyone help me plz? thanks in advance. CLEAR MY DOUBT IF U GENIUS

Just run a select query in the master database where the object is a database. anything in SQL Server has to be registered in the master database. When you create a table, stored proc, user etc. it is stored in the master database. Of course you need the correct permission to access the master database, but it is all there.

thanks sir.but i want to know what are all the databases avaliable in the SQLSERVER. for example... while we connecting the sqlserver through vb.net (OLEDB) we specify the username and password and just select the database know.the same thing i need in my application

just go through www.connectionstrings.com for all your db queries

- i gave all connection strings correctly. thats no problem sir.but i want to select "what are all the databases avaliable in SQLServer" (example....MASTER,TRAINEE,STUDENTS,....)..can u help me? thanks in advance

Just run a select query in the master database where the object is a database. anything in SQL Server has to be registered in the master database. When you create a table, stored proc, user etc. it is stored in the master database. Of course you need the correct permission to access the master database, but it is all there.

-
thanks sir.but i want to know what are all the databases avaliable in the SQLSERVER. for example... while we connecting the sqlserver through vb.net (OLEDB) we specify the username and password and just select the database know.the same thing i need in my application...can u help me? thanks in advance....

Ok i will try again.
In SQL Server there is a system database called Master. This is the heart of SQL Server. Whenever you add an object to SQL Server such as a database, a user, a stored proc, a table, a column etc. it is put into the master database. Go look at the master database tables and you will see all your databases in there.
So alll you have to do is write a query to select all from the table in the master database where the object type is a database. e.g. select * from dbo.master.the_table_with_the_databasenames where the_type = the_database_type.
That is as close as i will go but it is just that one line. I could give you the select query but you will learn a lot more about SQL Server if you figure it out yourself.

Or you can just "EXEC sp_databases" look it up in Books on line (the manual that comes with SQL Server) find it from Start -> All programs -> Microsoft SQl Server -> Books online.

Declare

'Add reference "Microsoft SQLDMO Object Library"
   Dim sqlServers As SQLDMO.NameList
    Dim sqlServerName As String

On event

sqlServers = New SQLDMO.Application().ListAvailableSQLServers

        For Each sqlServerName In sqlServers
            cboServerName.Items.Add(sqlServerName)
        Next

Sorry

in fact you can use
"select name from master..sysdatabases where name<>'master' and name<>'tempdb' and name<>'model' and name<>'msdb'"

This article has been dead for over six months. Start a new discussion instead.