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(Configuratio nManager.C onnectionS trings["Co nnectionSt ring"].Con nectionStr ing);
DataTable dt = new DataTable();
myConnection.Open();
try {
SqlCommand cmdLicense = new SqlCommand("SPR_SEARCH_USE RPROFILE", myConnection);
cmdLicense.CommandType = CommandType.StoredProcedur e;
cmdLicense.Parameters.AddW ithValue(" @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);=======err ors here
if (dt.Rows.Count > 0)
{
//GridView1.CurrentPageInd ex = 0;
GridView1.DataSource = dt;
GridView1.DataBind();
// lblmsg.Text = "";
GridView1.Enabled = true;
}
else
{
// lblmsg.Text = "User not found";
//dgUsers.Enabled = false;
}
}
========================== ========== ========== ========== ========== ========== =======
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(Configuratio
DataTable dt = new DataTable();
myConnection.Open();
try {
SqlCommand cmdLicense = new SqlCommand("SPR_SEARCH_USE
cmdLicense.CommandType = CommandType.StoredProcedur
cmdLicense.Parameters.AddW
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(
if (dt.Rows.Count > 0)
{
//GridView1.CurrentPageInd
GridView1.DataSource = dt;
GridView1.DataBind();
// lblmsg.Text = "";
GridView1.Enabled = true;
}
else
{
// lblmsg.Text = "User not found";
//dgUsers.Enabled = false;
}
}
==========================
DataTable dt = TaskDataAccess.SearchUser( userSearch , this.txtSearch.Text);
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
but i declared Task userSearch;
how comes i get this error saying "Use of unassigned local variable 'userSearch'"
DataTable dt = TaskDataAccess.SearchUser(
THANKS
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks