SqlCommand SQL statement 'stuck'

  • Thread starter Thread starter KevinRug
  • Start date Start date
K

KevinRug

In the code below, I am trying to change the select statment to be
"distinct" , ( i have also tried "top 1"), but when the code runs I always
get the original query "Select city from doctors".

Here is a code extract

SqlCommand cmdCities = new SqlCommand("Select city from doctors",
sqlConnection1);
SqlDataReader drCities;
sqlConnection1.Open();
drCities = cmdCities.ExecuteReader();
lstCities.DataSource = drCities;
lstCities.DataTextField = "City";
lstCities.DataBind();
drCities.Close();
sqlConnection1.Close();




Any ideas as to why the query changes are not being accepted?

Kevin Ruggles
 
I did not show all the code, but these are the 3 queries I have tried. They
all return the same result as the first query

Select city from doctors
Select top 1 city from doctors
Select distinct city from doctors
 
ok, whack me with a stick,

I found out the control, dropdownlistbox, was databound to a dataset, and it
was not looking at the query.
I removed the data binding and viola it works :)

thanks to all

kevin
 
Back
Top