|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
SqlCommand SQL statement 'stuck'"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 don't see any code trying to change the query.
Show quoteHide quote "KevinRug" <kevin***@discussions.microsoft.com> wrote in message news:OxqM97FQFHA.2932@TK2MSFTNGP09.phx.gbl... > 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 Show quoteHide quote "Marina" <someone@nospam.com> wrote in message news:utCik$FQFHA.2136@TK2MSFTNGP14.phx.gbl... > I don't see any code trying to change the query. > > "KevinRug" <kevin***@discussions.microsoft.com> wrote in message > news:OxqM97FQFHA.2932@TK2MSFTNGP09.phx.gbl... > > 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 > > > > > > Is this an asp.net project? Are you recompiling it before trying to load the
page again? Show quoteHide quote "KevinRug" <kevin***@discussions.microsoft.com> wrote in message news:ukZ08HGQFHA.2580@TK2MSFTNGP10.phx.gbl... >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 > > "Marina" <someone@nospam.com> wrote in message > news:utCik$FQFHA.2136@TK2MSFTNGP14.phx.gbl... >> I don't see any code trying to change the query. >> >> "KevinRug" <kevin***@discussions.microsoft.com> wrote in message >> news:OxqM97FQFHA.2932@TK2MSFTNGP09.phx.gbl... >> > 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 >> > >> > >> >> > > SELECT distinct city from doctors.
Try it. Alex Show quoteHide quote "KevinRug" <kevin***@discussions.microsoft.com> wrote in message news:OxqM97FQFHA.2932@TK2MSFTNGP09.phx.gbl... > 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 > > 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 Show quoteHide quote "KevinRug" <kevin***@discussions.microsoft.com> wrote in message news:OxqM97FQFHA.2932@TK2MSFTNGP09.phx.gbl... > 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 > >
Other interesting topics
How to look at parameter string
disconnected typed dataset DataAdapter Update Does Nothing ADO error "There is already an open DataReader associated with this Connection" SQLHelper.ExecuteReader - Connection Close Can't Read Excel File (OleDb) w/ ASP.NET Impersonation Filling multiple tables Oracle Data Providers (Connection Pooling & Transactions) Importing Excel data to Access Simple asynchronous method |
|||||||||||||||||||||||