Click here to Skip to main content
15,896,489 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I write this code for seaching but i got error "No overload for method SearchItem take '0' arguments " when i call it from other page coding.


public DataSet SearchItem(string title, string flag)
    {
        title =null;
        flag =null;
        bool @bool = false;
        StrQuery = "select * from content ";
        if (!string.IsNullOrEmpty(title))
        {
            StrQuery += " where title like '%" + title + "%'";
            @bool = true;
        }
        if (!string.IsNullOrEmpty(flag))
        {
            StrQuery += " " + flag;
        }
        else
        {
            StrQuery += " order by contentid asc";
        }
        return objGenralMothod.ExecuteSelectQur(StrQuery);
    }


Thanks ...

Rathod Narendra

[edit]Added <pre>...<.pre> tags to preserve the formatting.[/edit]
Posted
Updated 11-May-10 23:29pm
v2
Comments
OriginalGriff 12-May-10 5:31am    
BTW: It is a very bad idea to do SQL queries (which I assume you are) using direct text - Google for SQL Injection Attack for details. Use a Parameterized Query instead - look at SqlCommand.AddWithValue for details. [Edit]Corrected spelling of Query[/edit]

Your method definition is:
public DataSet SearchItem(string title, string flag)
I.e. it requires two parameters, both string.
When you try to call it, the error message means you are using:
DataSet ds = SearchItem();
I.e. you have not provided either parameter.
 
Share this answer
 
You are invoking it as SearchItem(), it should be SearchItem("xxx", "true")

Cheers
 
Share this answer
 
A couple of things. As Griff said, this code is ripe for people to attack your database, it's a mess. The second thing is, if you could not understand the meaning of the error message you got, you should focus on learning basic C# before you consider also learning SQL.
 
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