Loading All Database Name

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Mar 2007
Posts: 32
Reputation: karan_21584 is an unknown quantity at this point 
Solved Threads: 0
karan_21584 karan_21584 is offline Offline
Light Poster

Loading All Database Name

 
0
  #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
Reply With Quote Quick reply to this message  
Join Date: Jan 2006
Posts: 275
Reputation: f1 fan is an unknown quantity at this point 
Solved Threads: 11
f1 fan f1 fan is offline Offline
Posting Whiz in Training

Re: Loading All Database Name

 
0
  #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 Quick reply to this message  
Join Date: Mar 2007
Posts: 32
Reputation: karan_21584 is an unknown quantity at this point 
Solved Threads: 0
karan_21584 karan_21584 is offline Offline
Light Poster

Re: Loading All Database Name

 
0
  #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 Quick reply to this message  
Join Date: Nov 2006
Posts: 44
Reputation: amithasija is an unknown quantity at this point 
Solved Threads: 0
amithasija amithasija is offline Offline
Light Poster

Re: Loading All Database Name

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

Re: Loading All Database Name

 
0
  #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 Quick reply to this message  
Join Date: Mar 2007
Posts: 32
Reputation: karan_21584 is an unknown quantity at this point 
Solved Threads: 0
karan_21584 karan_21584 is offline Offline
Light Poster

Re: Loading All Database Name

 
0
  #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 Quick reply to this message  
Join Date: Jan 2006
Posts: 275
Reputation: f1 fan is an unknown quantity at this point 
Solved Threads: 11
f1 fan f1 fan is offline Offline
Posting Whiz in Training

Re: Loading All Database Name

 
0
  #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 Quick reply to this message  
Join Date: Feb 2005
Posts: 1,181
Reputation: hollystyles will become famous soon enough hollystyles will become famous soon enough 
Solved Threads: 67
hollystyles's Avatar
hollystyles hollystyles is offline Offline
Veteran Poster

Re: Loading All Database Name

 
0
  #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 Quick reply to this message  
Join Date: Oct 2007
Posts: 2
Reputation: s_muenchaisit is an unknown quantity at this point 
Solved Threads: 0
s_muenchaisit s_muenchaisit is offline Offline
Newbie Poster

Re: Loading All Database Name

 
0
  #9
Oct 29th, 2007
Declare
  1.  
  2. 'Add reference "Microsoft SQLDMO Object Library"
  3. Dim sqlServers As SQLDMO.NameList
  4. Dim sqlServerName As String
  5.  

On event
  1. sqlServers = New SQLDMO.Application().ListAvailableSQLServers
  2.  
  3. For Each sqlServerName In sqlServers
  4. cboServerName.Items.Add(sqlServerName)
  5. Next
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 2
Reputation: s_muenchaisit is an unknown quantity at this point 
Solved Threads: 0
s_muenchaisit s_muenchaisit is offline Offline
Newbie Poster

Re: Loading All Database Name

 
0
  #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 Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC