Answered by:
sqldatasource textbox control NULL problem

Question
-
User-1849419740 posted
i've a stored procedure and i wanna make searching by using textboxs.when the textbox3 and textbox5 is empty , it is required that all the records has come but there is no record.stored procedure @camera nvarchar(20), @three nvarchar (20), AND camera = coalesce(@camera, camera) AND three = coalesce(@three, three) <asp:SqlDataSource ID="SqlDataSource4" runat="server" ConnectionString ="<%$ ConnectionStrings:conn %>" SelectCommand="Urungoster"SelectCommandType ="StoredProcedure"> <SelectParameters> <asp:ControlParameter ControlID="TextBox3" Name="camera" PropertyName="Text" Type="String" ConvertEmptyStringToNull ="false"/> <asp:ControlParameter ControlID="TextBox5" Name="three" PropertyName="Text" Type="String" ConvertEmptyStringToNull="false"/>
Friday, March 25, 2011 3:48 AM
Answers
-
User77042963 posted
<asp:SqlDataSource ID="SqlDataSource4" runat="server CancelSelectOnNullParameter="false" ...>
Your stored procedure with default value null for the two parameters:
stored procedure .. @camera nvarchar(20)=null, @three nvarchar(20)=null .... SELECT * FROM yourTable WHERE ...AND (camera =@camera OR =@camera IS NULL)) AND (three = @three OR @three IS NULL)
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, March 28, 2011 10:21 PM
All replies
-
User1288251396 posted
Could you please clean up your posted code?
(It makes things a lot more readable if you use the Insert Code tool. If you need instructions, see this How to use the Forums' "Insert Code" tool post.)
Also, please post all related code, markup, and stored procedures.
Friday, March 25, 2011 9:31 AM -
User1295264499 posted
When you are passing parameter from your application via textbox it is sending an empty character '' and not null so colease might not work. I think you should use the wild charater '%' when parameter is empty or NULL.
Hope this help
Please mark as answer if this solve your problem
Monday, March 28, 2011 5:24 PM -
User77042963 posted
<asp:SqlDataSource ID="SqlDataSource4" runat="server CancelSelectOnNullParameter="false" ...>
Your stored procedure with default value null for the two parameters:
stored procedure .. @camera nvarchar(20)=null, @three nvarchar(20)=null .... SELECT * FROM yourTable WHERE ...AND (camera =@camera OR =@camera IS NULL)) AND (three = @three OR @three IS NULL)
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, March 28, 2011 10:21 PM