Click here to Skip to main content
16,019,614 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
In my database location fields is

chennai, mumbai, pune
chennai, mumbai
chennai, bangalore
bangalore, pune
delhi, pune
chennai
mummbai
chennai


If my doubt's I insert the textbox values is chennai means i want output like this
chennai, mumbai, pune
chennai, mumbai
chennai, bangalore
chennai
chennai


and I insert the another values is chennai, mumbai means i want output like this
chennai, mumbai, pune
chennai, mumbai
chennai, bangalore
chennai
chennai
mumbai


Plz find out the coding path asp.net or c#


Regards
Bala
Posted
Comments
Jαved 12-Apr-12 6:00am    
Please explain neatly. It's completely confusing.
Mohamed Mitwalli 12-Apr-12 8:05am    
Could you clarify more !!!
amitit1989 12-Apr-12 8:38am    
Please explain clearly, separately like design,database,code and then what do you want?

Capture the string that you are inserting into the text box and use the LIKE operator on the database to get matching results.

And sorry we can point you to right direction if there is a mistake,but we cannot code for you.


You can get some learning experience from here

http://www.homeandlearn.co.uk/csharp/csharp_s12p12.html[^]
 
Share this answer
 
C#
static void Main(string[] args)
        {
            List<string> sourceFromDB = new List<string> 
            { 
                "chennai, mumbai, pune"
                ,"chennai, mumbai"
                ,"chennai, bangalore"
                ,"bangalore, pune"
                ,"delhi, pune"
                ,"chennai"
                ,"mummbai"
                ,"chennai"
            };

            string text = "chennai,mummbai";

            // Start.  Maybe the follow code is what you need.^_^
            string[] allKey = (text ?? "").Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);
            List<string> result = (from sc in sourceFromDB
                                   let scTp = sc.Split(new char[]{',',' '},StringSplitOptions.RemoveEmptyEntries)
                                   where scTp.Distinct().Intersect(allKey).Count() > 0
                                   select sc).ToList();
            // End. 

            foreach (string str in result)
            {
                Console.WriteLine(str);
            }
            Console.ReadKey();
        }</string></string></string>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900