I have an sqldatasource in my asp.net site that has a parameter it gets from a control on the page. When I set the query on a number data column in the DB the datasource works perfect. However when I write the query on a string (char or varchar) column
in the DB it doesn't work. I made sure all the parameters are correct in the datasource. This is for an Oracle 11g database -- Below is my code:
sdprest
Member
35 Points
22 Posts
Problems with string parameters
Nov 11, 2011 10:29 PM|LINK
I have an sqldatasource in my asp.net site that has a parameter it gets from a control on the page. When I set the query on a number data column in the DB the datasource works perfect. However when I write the query on a string (char or varchar) column in the DB it doesn't work. I made sure all the parameters are correct in the datasource. This is for an Oracle 11g database -- Below is my code:
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:XXXXXX %>" ProviderName="<%$ ConnectionStrings:XXXXXX %>" SelectCommand="SELECT "IMAGEURL", "PRODUCTNAME", "MINHEIGHT", "MINWIDTH" FROM "PRODUCT" WHERE ("PRODUCTNAME" = :PRODUCT)"> <SelectParameters> <asp:ControlParameter ControlID="Label3" Name="PRODUCT" PropertyName="Text" Type="String" /> </SelectParameters> </asp:SqlDataSource><asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:XXXXXX %>" ProviderName="<%$ ConnectionStrings:XXXXXX %>" SelectCommand="SELECT "IMAGEURL", "PRODUCTNAME", "MINHEIGHT", "MINWIDTH" FROM "PRODUCT" WHERE ("PRODUCTID" = :PRODUCT)"> <SelectParameters> <asp:ControlParameter ControlID="Label3" Name="PRODUCT" PropertyName="Text" Type="Decimal" /> </SelectParameters> </asp:SqlDataSource>