No overload for method 'Forum' takes '1' arguments

Last post 05-19-2008 5:57 AM by Ivan Xin - MSFT. 13 replies.

Sort Posts:

  • No overload for method 'Forum' takes '1' arguments

    05-15-2008, 11:16 AM
    • Loading...
    • JohnnyJ
    • Joined on 01-09-2008, 8:14 AM
    • Posts 71
    I am getting this error - No overload for method 'Forum' takes '1' arguments
    Can anyone help?
    I am using a web service created by myself
     Topic Page
    <asp:HyperLinkField DataNavigateUrlFormatString="~/topic.aspx?TopicID={0}" NavigateUrl="~/topic.aspx" Text="Comments" DataNavigateUrlFields="TopicID" />
    Comments Page

    localhost.Topic topic = new localhost.Topic();

    string topicId = Request.QueryString["TopicID"].ToString();

    datasource = topic.Forum("SELECT * FROM Comment WHERE TopicID =" +topicId);

    GridView1.DataSource = datasource;

    GridView1.DataBind();

     

  • Re: No overload for method 'Forum' takes '1' arguments

    05-15-2008, 11:23 AM
    • Loading...
    • moises.dl
    • Joined on 09-12-2006, 11:17 AM
    • SLC
    • Posts 503

    somewhere in your code youre calling a method that takes either more than 1 parameter in the method or no parameters.

    +
    Lvl FIVE THOUSAND DRAGON MASTER SOFTWARE ENGINEER
    my friends call me MOI
  • Re: No overload for method 'Forum' takes '1' arguments

    05-15-2008, 11:25 AM
    Answer

    Please check out your Forum webservice method looks like it doesnt take a string parameter.

    There is some problem with signature. Make sure to pass your arguments according to what your Forum signature demands.

    If this does not solve your problem then please provide your Forum signature in your webservice here.

    Hope this helps.

  • Re: No overload for method 'Forum' takes '1' arguments

    05-15-2008, 12:21 PM
    • Loading...
    • JohnnyJ
    • Joined on 01-09-2008, 8:14 AM
    • Posts 71
    This might be a stupid question but what does Forum signature mean?
  • Re: No overload for method 'Forum' takes '1' arguments

    05-15-2008, 12:24 PM
    • Loading...
    • JohnnyJ
    • Joined on 01-09-2008, 8:14 AM
    • Posts 71

    The topicid is a auto-generated number, would that cause this problem?

  • Re: No overload for method 'Forum' takes '1' arguments

    05-15-2008, 12:47 PM
    Answer
    • Loading...
    • moises.dl
    • Joined on 09-12-2006, 11:17 AM
    • SLC
    • Posts 503

    when you call a method it will have 0 or more parameters those parameters are called the method signature, and what that signature is, is its telling you what it needs to perform that method .... for example if you do

    string my = "";

    my.ToCharArray();

    the first intellesence will show no parameters and the signature would be blank or empty

    but if i push down while intelesense is up you will see the signature change to

    my.ToCharArray(int startIndex, int Length);

    now the signature is                   int  startindex, int length

    meaning to run that method you HAVE to give it either nothing OR you have to get it an int, which will represent where to start making this array, and an int which tells the method how long to make the array.....

     

    now in your case if youre calling a method and not giving it the proper parameters that its asking for in the signature, then it will throw an error and tell you such, SO in conclusion... try to put a breakpoint at the beginning of your logic and when it breaks or throws an error then you know which method does not have valid params

     

    get it? or if you dont ill try to explain more

    +
    Lvl FIVE THOUSAND DRAGON MASTER SOFTWARE ENGINEER
    my friends call me MOI
  • Re: No overload for method 'Forum' takes '1' arguments

    05-15-2008, 12:48 PM
    • Loading...
    • moises.dl
    • Joined on 09-12-2006, 11:17 AM
    • SLC
    • Posts 503

    if you want to paste your code i can try to figure out which method is nutso

    +
    Lvl FIVE THOUSAND DRAGON MASTER SOFTWARE ENGINEER
    my friends call me MOI
  • Re: No overload for method 'Forum' takes '1' arguments

    05-15-2008, 1:51 PM
    • Loading...
    • JohnnyJ
    • Joined on 01-09-2008, 8:14 AM
    • Posts 71

     <xs:element name="ForumID" type="xs:int" minOccurs="0" />

    Thats what it states within the web service

  • Re: No overload for method 'Forum' takes '1' arguments

    05-15-2008, 2:40 PM

    Hi Johnny

    A signature means what your method looks like its returntype & parameters.

    I think you are passing an integer, this is what your last post suggests.

    Make the following changes & you will be good:

    Change No.1
    //topic.Forum should only pass topicId as parameter

    localhost.Topic topic = new localhost.Topic();

    string topicId = Request.QueryString["TopicID"].ToString();

    datasource = topic.Forum(topicId);

    GridView1.DataSource = datasource;

    GridView1.DataBind();


    Change No.2
    //Change your Forum parameter to take string

    Forum(sting topicId)
    {
    //write your code to fire the query
    //SELECT * FROM Comment WHERE TopicID =" +topicId
    }

    Hope this helps.

    Thanks

    Abhishek 

     

  • Re: No overload for method 'Forum' takes '1' arguments

    05-15-2008, 3:09 PM
    • Loading...
    • JohnnyJ
    • Joined on 01-09-2008, 8:14 AM
    • Posts 71

    localhost.Topic topic = new localhost.Topic();

    string topicId = Request.QueryString["TopicID"].ToString();

    datasource = topic.Forum(topicId);

    GridView1.DataSource = datasource;

    GridView1.DataBind();

    This is the new code. I dont understand where this goes:

    Forum(sting topicId)
    {
    //write your code to fire the query
    //SELECT * FROM Comment WHERE TopicID =" +topicId
    }

  • Re: No overload for method 'Forum' takes '1' arguments

    05-16-2008, 2:42 AM

    Hi

    This code goes into your Forum webservice method. You take the topicId as string & then issue a query for the database.

     

  • Re: No overload for method 'Forum' takes '1' arguments

    05-16-2008, 8:41 AM
    • Loading...
    • JohnnyJ
    • Joined on 01-09-2008, 8:14 AM
    • Posts 71

    [WebMethod]
        public DataSet GetDataSetForum2()
        {
            DataSet datasource = new DataSet();
            string database = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|/topic.mdb;Persist Security Info=True";
            string queryStr = "Select * from Comment";
            OleDbConnection myConn = new OleDbConnection(database);
            OleDbDataAdapter myDataAdapter = new OleDbDataAdapter(queryStr, myConn);
            myConn.Open();
            myDataAdapter.Fill(datasource, "Comment");
            myConn.Close();
            return datasource;
        }

    localhost.Topic topic = new localhost.Topic();

    string topicId = Request.QueryString["TopicID"].ToString();

    string id = "SELECT * FROM Post WHERE ForumID='" + topicId + "'"; 

    datasource = topic.GetDataSetForum2(id);

    GridView1.DataSource = datasource;

    GridView1.DataBind();

    topicid is a int not a string if that makes any difference.

    So does a query string need to be within the webservice? I have noticed that there are two querystrings,however if I remove the querystring from the web service it doesnt display anything, as its not querying the table I think? I added the querystring which is located within the website however it stated that the topicid could not be found, so I added that but then it didnt like the response statement.

    Thank you for your help

  • Re: No overload for method 'Forum' takes '1' arguments

    05-17-2008, 4:17 AM
    • Loading...
    • JohnnyJ
    • Joined on 01-09-2008, 8:14 AM
    • Posts 71

    localhost.Topic topic = new localhost.Topic();

    string topicId = Request.QueryString["TopicID"].ToString();

    public DataSet GetDataSetForum2(string id)
    {

    "SELECT * FROM Post WHERE ForumID='" + topicId + "'";

    datasource = topic.GetDataSetForum2(id);

    GridView1.DataSource = datasource;

    GridView1.DataBind();

    This code is within the pageload within a try and catch statement. When I added the public dataset I got alot of errors. Have I put it in the wrong place?

  • Re: No overload for method 'Forum' takes '1' arguments

    05-19-2008, 5:57 AM
    Answer

    Hi johnny,

           Your GetDataSetForum2 method is almost completely a disaster. As I can see you have totally no idea of the C# basis. I strongly recommand you to learn this language first, and then turn back here to ask a more specific question.

    For the method I can help you do some corrections here:

    public DataSet GetDataSetForum2(string id)

    {

    SqlConnection conn =
        new SqlConnection("server=.;uid=sa;pwd=;database=pubs");

        SqlCommand sqlcom=new SqlCommand();

        sqlcom.CommanText="SELECT * FROM Post WHERE ForumID='" + topicId + "'";

        SqlDataAdapter da =
              new SqlDataAdapter(sqlcom,conn);

        DataSet ds = new DataSet();
        da.Fill(ds, "Authors");

         return ds;
    }

    Regards,

    Ivan.

Page 1 of 1 (14 items)