User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 391,906 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,577 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 1708 | Replies: 9
Reply
Join Date: Mar 2007
Posts: 30
Reputation: karan_21584 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
karan_21584 karan_21584 is offline Offline
Light Poster

Question Loading All Database Name

  #1  
Mar 23rd, 2007
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
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jan 2006
Location: Its the internet... i am everywhere lol
Posts: 274
Reputation: f1 fan is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 10
f1 fan f1 fan is offline Offline
Posting Whiz in Training

Re: Loading All Database Name

  #2  
Mar 23rd, 2007
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.
Reply With Quote  
Join Date: Mar 2007
Posts: 30
Reputation: karan_21584 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
karan_21584 karan_21584 is offline Offline
Light Poster

Re: Loading All Database Name

  #3  
Mar 26th, 2007
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
Reply With Quote  
Join Date: Nov 2006
Location: new delhi
Posts: 38
Reputation: amithasija is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
amithasija amithasija is offline Offline
Light Poster

Re: Loading All Database Name

  #4  
Mar 26th, 2007
just go through www.connectionstrings.com for all your db queries
Reply With Quote  
Join Date: Mar 2007
Posts: 30
Reputation: karan_21584 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
karan_21584 karan_21584 is offline Offline
Light Poster

Re: Loading All Database Name

  #5  
Mar 26th, 2007
Originally Posted by amithasija View Post
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
Reply With Quote  
Join Date: Mar 2007
Posts: 30
Reputation: karan_21584 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
karan_21584 karan_21584 is offline Offline
Light Poster

Re: Loading All Database Name

  #6  
Mar 26th, 2007
Originally Posted by f1 fan View Post
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....
Reply With Quote  
Join Date: Jan 2006
Location: Its the internet... i am everywhere lol
Posts: 274
Reputation: f1 fan is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 10
f1 fan f1 fan is offline Offline
Posting Whiz in Training

Re: Loading All Database Name

  #7  
Mar 26th, 2007
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.
Reply With Quote  
Join Date: Feb 2005
Location: Braintree, UK
Posts: 1,164
Reputation: hollystyles will become famous soon enough hollystyles will become famous soon enough 
Rep Power: 7
Solved Threads: 58
hollystyles's Avatar
hollystyles hollystyles is offline Offline
Veteran Poster

Re: Loading All Database Name

  #8  
Mar 26th, 2007
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.
==========================================
Yadda yadda yadda...
Web junky, fevered monkey
Reply With Quote  
Join Date: Oct 2007
Posts: 2
Reputation: s_muenchaisit is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
s_muenchaisit s_muenchaisit is offline Offline
Newbie Poster

Re: Loading All Database Name

  #9  
Oct 29th, 2007
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
Reply With Quote  
Join Date: Oct 2007
Posts: 2
Reputation: s_muenchaisit is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
s_muenchaisit s_muenchaisit is offline Offline
Newbie Poster

Re: Loading All Database Name

  #10  
Oct 29th, 2007
Sorry

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

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb ASP.NET Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the ASP.NET Forum

All times are GMT -4. The time now is 7:43 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC