You must Sign In to post a response.
  • Category: SQL Server

    Search many parameters having space

    I am using a search funtion that will search some files according to the filename.
    I want to pass parameters like" ab cd ef ". It will search the filename at first ab if yes then will find cd if yes then ef like this...how to do this...I think I should use array and check...but I cant do...need help.
  • #761810
    string[] SearchArray = "ab cd ef ".split(' ');

    you will get the array of search items. By using for loop you can implement you logic.

    By Nathan
    Direction is important than speed

  • #761833
    Hi

    You can follow this steps

    you call added one method for checking string this code


    private void Receievemethod(string a)
    {
    string ff = a.Split(' ')[0];
    if (ff == "ab")
    {
    //Code here
    }
    else
    if (ff == "cb")
    {
    //Code here
    }
    if (ff == "ef")
    {
    //Code here
    }
    }


    How to call this method from button click event

    Receievemethod("ab cd ef");


    When the button click event passing your parameter then we can check separate method for checking string then what process do you need do them.

    Name : Dotnet Developer-2015
    Email Id :kumaraspcode2009@gmail.com

    'Not by might nor by power, but by my Spirit,' says the LORD Almighty.

  • #761834
    Hi
    You can check code also for array parameters

    Method

    private void Receievemethod(string a)
    {
    string[] ff = a.Split(' ');

    for (int i = 0; i <= ff.Length - 1; i++)
    {
    if (ff[i] == "ab")
    {
    //Code here
    }
    else
    if (ff[i] == "cb")
    {
    //Code here
    }
    if (ff[i] == "ef")
    {
    //Code here
    }
    }
    }


    How to call this method from button click


    Receievemethod("ab cd ef");


    I have pass this string then receives in array then checking every element and do your process there.

    Name : Dotnet Developer-2015
    Email Id :kumaraspcode2009@gmail.com

    'Not by might nor by power, but by my Spirit,' says the LORD Almighty.

  • #761838
    hello Kumar sir
    your code is good...I have one query...I have passed here known parameter like ab bc cd. But in general not only this string will be passed may be another, then how to get those string and compare?

  • #761840
    Hi

    You can try this code

    In the Button click event


    Receievemethod(txtPassString.Text);


    Checking string here


    private void Receievemethod(string a)
    {
    string[] ff = a.Split(' ');

    for (int i = 0; i <= ff.Length - 1; i++)
    {
    if (ff[i] == a)
    {
    //Code here
    }
    else
    if (ff[i] == a)
    {
    //Code here
    }
    if (ff[i] == a)
    {
    //Code here
    }
    }
    }

    Name : Dotnet Developer-2015
    Email Id :kumaraspcode2009@gmail.com

    'Not by might nor by power, but by my Spirit,' says the LORD Almighty.

  • #761841
    Hi

    You can check this code for your input string


    Receievemethod(txtPassString.Text);


    Receives method


    private void Receievemethod(string a)
    {
    string[] ff = a.Split(' ');

    for (int i = 0; i <= ff.Length - 1; i++)
    {
    if (ff[i] == a.Split(' ')[0])
    {
    //Code here
    }
    else
    if (ff[i] == a.Split(' ')[0])
    {
    //Code here
    }
    if (ff[i] == a.Split(' ')[0])
    {
    //Code here
    }
    }
    }

    Name : Dotnet Developer-2015
    Email Id :kumaraspcode2009@gmail.com

    'Not by might nor by power, but by my Spirit,' says the LORD Almighty.

  • #761864
    hi all your code is giving the same result as i am doing in following way like..
    select * from consfiles where filename LIKE '%' + @parafilename + '%' order by dateofsubmit desc

    But I passed like "animal picture"
    so first it will search only" animal"keyword...then among them it will find out picture..
    like data are
    1.animal doc
    2.animal pinguin picture 1
    3.picture
    4.animal pdf
    5.animal picture 2 so result will be 2,5 and I will bind in gridview. how to do that


Sign In to post your comments