Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Professional
|
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 12th, 2006, 01:08 AM
Registered User
 
Join Date: Jun 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to Vinay Chugh
Default User Value in TextBox be passed in SQL LIKE Clause

Hi all !
I need some clue form u guys !
I have a webform in which i have a textbox in which user is supposed to enter some value.
Once entered, the database will be searched for all those values which are contained in the Textbox and output will be shown in a ListBox.

I am using ASP.NET 1.1 with C# and is unable to get the output.
the Sql query i wrote is :
"SELECT Company_Name FROM CompanyName WHERE Company_Name LIKE '%" &val& "%'";

where val=TextBox1.text

Please somebody provide the solution

Vinay Chugh

If I rest, I will rust ! Let's share the knowledge !
 
Old June 12th, 2006, 07:22 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

This should work for you:

"SELECT Company_Name FROM CompanyName where Company_Name Like '" &val & "%'";

You aren't very specific as to what your problem is here though, you are using a LIKE here but it sounds like a user may be able to enter multiple values in the textbox. (e.g., Company1, Company2) which then changes your SQL Query to this

"SELECT Company_Name FROM CompanyName where Company_Name IN ('" & val &"')";

Be mindful of special characters in the text box as well, if someone enters Mike's Company that is going to cause your SQL statement to fail because of the aposterphe.

Hope this helps.

-Doug

"The one language all programmers understand is profanity."





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to use login user name in where clause? gsrai31 ASP.NET 2.0 Basics 7 November 22nd, 2008 04:49 AM
SQL Where Clause sudarshan73 Crystal Reports 2 January 11th, 2006 10:01 AM
How grap the passed value in select where clause method ASP.NET 1.x and 2.0 Application Design 1 June 16th, 2005 10:53 AM
sql parameters not passed or received redeye2 Pro VB.NET 2002/2003 1 November 5th, 2004 07:10 PM
Vars passed to SQL Stored Procedures deanglass ASP.NET 1.0 and 1.1 Basics 1 March 15th, 2004 05:35 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.