944,079 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 3545
  • ASP.NET RSS
Mar 23rd, 2007
0

Loading All Database Name

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
karan_21584 is offline Offline
32 posts
since Mar 2007
Mar 23rd, 2007
0

Re: Loading All Database Name

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.
Reputation Points: 26
Solved Threads: 11
Posting Whiz in Training
f1 fan is offline Offline
275 posts
since Jan 2006
Mar 26th, 2007
0

Re: Loading All Database Name

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
Reputation Points: 10
Solved Threads: 0
Light Poster
karan_21584 is offline Offline
32 posts
since Mar 2007
Mar 26th, 2007
0

Re: Loading All Database Name

just go through www.connectionstrings.com for all your db queries
Reputation Points: 10
Solved Threads: 0
Light Poster
amithasija is offline Offline
44 posts
since Nov 2006
Mar 26th, 2007
0

Re: Loading All Database Name

Click to Expand / Collapse  Quote originally posted by amithasija ...
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
Reputation Points: 10
Solved Threads: 0
Light Poster
karan_21584 is offline Offline
32 posts
since Mar 2007
Mar 26th, 2007
0

Re: Loading All Database Name

Click to Expand / Collapse  Quote originally posted by f1 fan ...
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....
Reputation Points: 10
Solved Threads: 0
Light Poster
karan_21584 is offline Offline
32 posts
since Mar 2007
Mar 26th, 2007
0

Re: Loading All Database Name

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.
Reputation Points: 26
Solved Threads: 11
Posting Whiz in Training
f1 fan is offline Offline
275 posts
since Jan 2006
Mar 26th, 2007
0

Re: Loading All Database Name

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.
Reputation Points: 262
Solved Threads: 68
Veteran Poster
hollystyles is offline Offline
1,181 posts
since Feb 2005
Oct 29th, 2007
0

Re: Loading All Database Name

Declare
ASP.NET Syntax (Toggle Plain Text)
  1.  
  2. 'Add reference "Microsoft SQLDMO Object Library"
  3. Dim sqlServers As SQLDMO.NameList
  4. Dim sqlServerName As String
  5.  

On event
ASP.NET Syntax (Toggle Plain Text)
  1. sqlServers = New SQLDMO.Application().ListAvailableSQLServers
  2.  
  3. For Each sqlServerName In sqlServers
  4. cboServerName.Items.Add(sqlServerName)
  5. Next
Reputation Points: 10
Solved Threads: 0
Newbie Poster
s_muenchaisit is offline Offline
2 posts
since Oct 2007
Oct 29th, 2007
0

Re: Loading All Database Name

Sorry

in fact you can use
"select name from master..sysdatabases where name<>'master' and name<>'tempdb' and name<>'model' and name<>'msdb'"
Reputation Points: 10
Solved Threads: 0
Newbie Poster
s_muenchaisit is offline Offline
2 posts
since Oct 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: can't find entrypoint Error 453
Next Thread in ASP.NET Forum Timeline: Webform - Loading an aspx page within a page





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC