Link to home
Start Free TrialLog in
Avatar of SirReadAlot
SirReadAlot

asked on

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

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;
        }
    }
===================================================================================
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

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

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thanks