Solved

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

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

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 143

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

680 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