TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
neethu
NA
37
16.6k
Split string and use with LIKE keyword in SQL Server
Sep 13 2012 1:47 AM
hi all,
Here i want to split the CustNm values from table with spaces and search with each word. how to do that? If i type" ba" in textbox it should display only values starting with ba
[WebMethod]
public static List<string> GetAutoCompleteDetails(string custdetails, string city)
{
List<string> result = new List<string>();
using (SqlConnection con = new SqlConnection("Data Source=SHAAN\\SQLEXPRESS;
Initial Catalog=DataPublishers;
User ID=sa;
Password=admin123")) {
using (SqlCommand cmd = new SqlCommand("select distinct CustNm from DP_details Where CustNm like @DetailsText+'%' and ADD3 = @City", con)) {
con.Open();
cmd.Parameters.AddWithValue("@DetailsText", custdetails);
cmd.Parameters.AddWithValue("@City", city);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read()) {
result.Add(dr["CustNm"].ToString());
}
return result;
}
}
}
eg
Ba
kers
Home
Ba
kers
State
ba
nk Of India
Not A
ba
d Homes (This should not list)
How to change the query?
Thanks & Regards
Neethu
Reply
Answers (
1
)
how to do the Link without open new window..?
Hiding gridview column for particular condition