Solved

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

Posted on 2007-11-16
4
692 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.

932 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

15 Experts available now in Live!

Get 1:1 Help Now