SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 need help..
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

a4u6178
Starting Member

India
11 Posts

Posted - 07/30/2011 :  01:18:15  Show Profile  Reply with Quote
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

USA
36831 Posts

Posted - 07/30/2011 :  01:20:55  Show Profile  Visit tkizer's Homepage  Reply with Quote
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

India
52317 Posts

Posted - 07/30/2011 :  01:23:36  Show Profile  Reply with Quote
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

India
11 Posts

Posted - 07/30/2011 :  02:00:32  Show Profile  Reply with Quote
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

India
11 Posts

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

Thanks & Regards,
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000