Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 need help..

Author  Topic 

a4u6178
Starting Member

11 Posts

Posted - 2011-07-30 : 01:18:15
Hello everyone,

Is there any way to know all database names existing in sql server.

Looking forward for replys...

Thanks & Regards,

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-07-30 : 01:20:55
Yes, query master.sys.databases.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-07-30 : 01:23:36
or sp_databases

http://msdn.microsoft.com/en-us/library/ms176070.aspx

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

a4u6178
Starting Member

11 Posts

Posted - 2011-07-30 : 02:00:32
thanks for immediate replys..
I was trying to bring all the database names in a dropdownlist..
Here is my code ..

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
populateddl();
}
}

private void populateddl()
{
using (SqlDataAdapter sda = new SqlDataAdapter("exec sp_databases", conn))
{
using(DataSet ds = new DataSet())
{
sda.Fill(ds);
DropDownList8.DataSource = ds;
DropDownList8.DataBind();
}
}
}
em not able to get the names in the dropdownlist, pls help me in this scenario..
when run the application what em getting is..
system.data.datarowview
as items of dropdownlist instead of this i should get names of databases
Looking forward for ur replys

Thanks & Regards,
Go to Top of Page

a4u6178
Starting Member

11 Posts

Posted - 2011-08-04 : 05:40:38
To bind dropdownllist i modified the code like this ..
DropDownList8.DataTextField = "DATABASE_NAME";
DropDownList8.DataValueField = "DATABASE_SIZE";

Thanks & Regards,
Go to Top of Page
   

- Advertisement -