SqlDataSource and Query String Parameters
Posted by: James McConnell
Date: August 23, 2007 02:23PM

I have a question. I have started a ASP.NET project for a new website, and I am able to connect to my MySQL database, but I have a SqlDataSource with SelectCommand that requires a value from the query string. For some reason, it's not working (as in returning nothing), and when I spit out the SelectCommand, my required value is not filled in. Here is my relevant information:

<asp:SqlDataSource ID="dsCatDetails" runat="server" ConnectionString="Server=server;User ID=user;Password=pass;Database=database;Persist Security Info=True" EnableCaching="True" ProviderName="MySql.Data.MySqlClient" SelectCommand="SELECT s.site_title AS title, s.site_url AS url, s.site_desc AS description, s.site_hits AS hits, s.site_IsNew AS new, s.site_IsPopular AS popular, s.site_rating AS rating, s.site_votes AS votes, s.site_graphic AS image FROM sites AS s, site_cat AS sc WHERE s.site_id = sc.site_id AND sc.cat_id='?CatId';" OnSelected="dsCatDetails_Selected">
<SelectParameters>
<asp:QueryStringParameter Name="CatId" QueryStringField="cat_id" Type="String" />
</SelectParameters>
</asp:SqlDataSource>

I know that looks ugly, but the main point is that I want to match "sc.cat_id" to the value of the query string variable "cat_id". This isn't happening. I registered a Selected event on the data source to write out the SelectCommand after the select statement has been executed, and it is exactly as above, without the "cat_id" value filled in.

Any suggestions? Thanks a ton.

James

Options: ReplyQuote


Subject
Written By
Posted
SqlDataSource and Query String Parameters
August 23, 2007 02:23PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.