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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Rekha SinghPosted Dec 30, 2009, 5:08 AM
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.
Rekha SinghPosted Dec 31, 2009, 7:16 AM
select CATALOG_NAME from INFORMATION_SCHEMA.SCHEMATA
Santhosh NPosted Dec 31, 2009, 6:25 AM
Gaurish KumarPosted Dec 31, 2009, 3:19 AM
Use this query to get all the database list
select name from master..sysdatabases
manoj kumarPosted Dec 31, 2009, 2:18 AM
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....
Hiren SoniPosted Dec 30, 2009, 7:14 AM
Lalit MPosted Dec 30, 2009, 7:06 AM
http://www.dotnetheaven.com/UploadFile/rahul4_saxena/dropdownlisiindatagrid05082007024918AM/dropdownlisiindatagrid.aspx
if vb.net
Kumar DuvvarapuPosted Dec 30, 2009, 6:20 AM
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
Santhosh NPosted Dec 30, 2009, 5:13 AM
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();