Solved

the best overloaded method match for 'TaskDataAccess.SearchUser(Task, string)' has some invalid arguments

Posted on 2007-11-16
4
681 Views
Last Modified: 2012-05-05
Hi experts,
how do i fix the above error?
in my class file i have this code
=====================================
public static DataTable SearchUser(Task userSearch, string search)
 {
     SqlConnection myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
     DataTable dt = new DataTable();
     myConnection.Open();
       try {
           SqlCommand cmdLicense = new SqlCommand("SPR_SEARCH_USERPROFILE", myConnection);
         cmdLicense.CommandType = CommandType.StoredProcedure;
         cmdLicense.Parameters.AddWithValue("@search", search);
         SqlDataAdapter adapter = new SqlDataAdapter(cmdLicense);
         adapter.Fill(dt);
     }
    catch (SqlException sqlexp)
       {
       
           throw (sqlexp);
     }
     myConnection.Close();
     return dt;
 }

======================in my code behind i tried to call SearchUser=================
 protected void btnSearch_Click(object sender, EventArgs e)
    {
        Task userSearch;
        //makes a call to SearchUser function
        DataTable dt = TaskDataAccess.SearchUser(userSearch, this.txtSearch);=======errors here
       if (dt.Rows.Count > 0)
        {
            //GridView1.CurrentPageIndex = 0;
            GridView1.DataSource = dt;
            GridView1.DataBind();
          //  lblmsg.Text = "";
            GridView1.Enabled = true;
        }
        else
        {
           // lblmsg.Text = "User not found";
            //dgUsers.Enabled = false;
        }
    }
===================================================================================
0
Comment
Question by:SirReadAlot
  • 2
  • 2
4 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 20297169
       DataTable dt = TaskDataAccess.SearchUser(userSearch, this.txtSearch.Text);
0
 

Author Comment

by:SirReadAlot
ID: 20297186
ohh, i forgot the text.

but i declared Task userSearch;

how comes i get this error saying "Use of unassigned local variable 'userSearch'"

 DataTable dt = TaskDataAccess.SearchUser(userSearch, this.txtSearch.Text);

THANKS
0
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 20297204
>but i declared Task userSearch;
yes, declared, but not initialized-

Task userSearch = new Task();

might need additional parameters for the Task() constructor
0
 

Author Closing Comment

by:SirReadAlot
ID: 31409523
thanks
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This video discusses moving either the default database or any database to a new volume.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now