x
login about faq Site discussion (meta-askssc)

Clarification in like command

hi everybody

i am a beginner in sql.. i need a clarification

                    
sqlcommand com=new sqlcommand("Select * from Registration where UserName like %@UserName%",con)                    
com.parameters.add("@UserName",sqldbtype.varchar,128).value='d';                    
sqlDataAdapter adp=new sqlDataAdapter(com);                    
Datattable dt=new Datatable();                    
adp.fill(dt);                    
return dt;                    

but i am not getting the value..how to pass parameter in like command

more ▼

asked Jan 28 '10 at 04:44 AM in Default

Balaji gravatar image

Balaji
1

(comments are locked)
10|1200 characters needed characters left

1 answer: sort voted first

Change the SQL to:
Select * from Registration where UserName like '%' + @UserName + '%'

more ▼

answered Jan 28 '10 at 05:15 AM

Kristen gravatar image

Kristen ♦
2.2k 6 7 10

(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments



Facebook logo Follow Ask SSC on Facebook
Find Ask SSC on Google+
linkedin logo Find us on LinkedIn

Topics:

x455

asked: Jan 28 '10 at 04:44 AM

Seen: 157 times

Last Updated: Jan 28 '10 at 05:14 AM

Copyright © 2002-2012 Simple Talk Publishing. All Rights Reserved. If you have any queries, please contact the site administrators.
Ask SQL Server Central is a community service provided by Red Gate.