Hi...
I want to Bind all database name of sql server in dropdownlist..pls help someone..
How to Bind.....
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Rekha SinghRank #1,571 · 1K reputationPosted Dec 30, 2009, 12:08 AM EST
just use the following code for binding all database name in an DropDownList
string sqlText = "select CATALOG_NAME from INFORMATION_SCHEMA.SCHEMATA ";
SqlConnection connection = new SqlConnection("ur connection string");
connection.Open();
DataSet ds = new DataSet();
SqlDataAdapter ad = new SqlDataAdapter(sqlText, connection);
ad.Fill(ds);
DropDownList1.DataSource = ds.Tables[0];
DropDownList1.DataTextField= "CATALOG_NAME";
DropDownList1.DataBind();
*****************************************
Please mark it Accepted if u find it helpful.
Santhosh NRank #4,788 · 325 reputationPosted Dec 30, 2009, 12:13 AM EST
you can try this code and bind all the database names in the particular server..
SqlConnection sqlConn = new SqlConnection("connection string");
sqlConn.Open();
SqlCommand sqlComm = new SqlCommand("SELECT name FROM master.sysdatabases", sqlConn);
SqlDataReader myReader = sqlComm.ExecuteReader();
while (myReader.Read())
{
ddlDataBaseList.Items.Add(myReader[0]);
}
sqlConn.Close();
Kumar Duvvarapu37 reputationPosted Dec 30, 2009, 1:20 AM EST
Please read the below link:
http://www.eggheadcafe.com/community/aspnet/13/10053076/how-to-get-list-of-all-da.aspx
Hope this will help you.
Thanks and Regards,
Kumar
Lalit MRank #1,186 · 1.5K reputationPosted Dec 30, 2009, 2:06 AM EST
http://www.dotnetheaven.com/UploadFile/rahul4_saxena/dropdownlisiindatagrid05082007024918AM/dropdownlisiindatagrid.aspx
if vb.net
Hiren SoniRank #694 · 3.5K reputationPosted Dec 30, 2009, 2:14 AM EST
manoj kumar124 reputationPosted Dec 30, 2009, 9:18 PM EST
your Article is very fantastic....but i want display all databse name...bt you artile display only particular database name..pls tell me wt shou;d I do? pls help me....
Gaurish Kumar108 reputationPosted Dec 30, 2009, 10:19 PM EST
Use this query to get all the database list
select name from master..sysdatabases
Santhosh NRank #4,788 · 325 reputationPosted Dec 31, 2009, 1:25 AM EST
Rekha SinghRank #1,571 · 1K reputationPosted Dec 31, 2009, 2:16 AM EST
select CATALOG_NAME from INFORMATION_SCHEMA.SCHEMATA