try
{
using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["connString"].ConnectionString))
{
conn.Open();
using (SqlCommand cmd = new SqlCommand("Select * FROM [tbl_data] ORDER BY main", conn))
{
cmd.CommandType = CommandType.Text;
using (SqlDataReader reader = cmd.ExecuteReader())
{
if (reader.HasRows)
{
while (reader.Read())
{
NameAndCounty = reader["NameAndCounty"].ToString();
Id = reader["Id"].ToString();
ddlNameAndCounty.Items.Add(new ListItem(NameAndCounty, Id));
}
}
}
}
}
}
catch (Exception ex)
{
return ex.Message.Trim();
}
No comments:
Post a Comment