I am trying to populate a dropdownlist with the name of the tables in my SQL database. This is my code attempt but nothing is happening when I call it and the dropdownlist stays empty.
public void FillDropDownList()
{
String connString = "myConnectionString";
//**STRING UPDATED**
String Query = "SELECT * FROM information_schema.tables";
using (var cn = new SqlConnection(connString))
{
cn.Open();
DataTable dt = new DataTable();
try
{
SqlCommand cmd = new SqlCommand(Query, cn);
SqlDataReader myReader = cmd.ExecuteReader();
dt.Load(myReader);
}
catch (SqlException e)
{
//to be completed
}
radDropDownList1.DataSource = dt;
radDropDownList1.ValueMember = "TABLES_NAME";
radDropDownList1.DisplayMember = "TABLES_NAME";
}
}
How can I populate the dropdownlist with the above query?
Postback.,