|
-
February 8th, 2005, 05:39 PM
#1
SqlCommand Text problem
Hi,
I have a 2 drop down lists. The first list contains alphabets from A-Z. When the user selects a an alphabet in the first list, the second list gets populated (from the database) with all customer names beginning with that alphabet.
But I am facing problem with the SQL command to get values from the
Database.I am using the sqlCommand text as :
SELECT CustName FROM Table WHERE (CustName LIKE @x)
Here @x (the parameter) is the alphabet which the user selects from the
first dropdown list. Now, I want all CustNames which start with the letter
chosen by the user.
I tried the command with a % sign after the parameter like
SELECT CustName FROM Table WHERE (CustName LIKE @x%)
but it said Syntax is wrong. I even tried '@x*' and '@x%' and even @x %25 , but nothing
seems to work.
What is the right syntax for this?
Please help.
Thanks
-
February 8th, 2005, 06:00 PM
#2
Re: SqlCommand Text problem
Hi,
I found out the answer. the correct syntax is SELECT CustName from table WHERE (CustName Like @x +'%').
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|