2 Replies - 4198 Views - Last Post: 07 February 2011 - 07:22 AM Rate Topic: -----

#1 SimonYu123  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 07-February 11

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

Posted 07 February 2011 - 06:59 AM

using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using wuoiTableAdapters;

/// <summary>
/// Summary description for Prayer
/// </summary>

[System.ComponentModel.DataObject]
public class Prayer
{
    private PrayerTableAdapter _prayerAdapter = null;
    protected PrayerTableAdapter Adapter
    {
        get 
	    {
		if (_prayerAdapter == null)
		_prayerAdapter = new PrayerTableAdapter();
        return _prayerAdapter;
	    }
    }

    [System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select, true)]
    public wuoi.PrayerDataTable GetPrayerContent()
    {
        return Adapter.GetPrayerContent();
    }

    [System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select, false)]
    public wuoi.PrayerDataTable GetPrayerContentByPrayerID(int prayerID)
    {
        return Adapter.GetPrayerContentByPrayerID(prayerID);
    }

    /// <summary>
    /// Update the prayer item
    /// </summary>
    /// <param name="dateCreate"></param>
    /// <param name="prayerContent"></param>
    /// <param name="prayerID"></param>
    /// <returns></returns>


    [System.ComponentModel.DataObjectMethodAttribute
        (System.ComponentModel.DataObjectMethodType.Update, true)]
    public bool UpdatePrayer(string dateCreate, string prayerContent, int prayerID)
    {
        wuoi.PrayerDataTable prayer = Adapter.GetPrayerContentByPrayerID(prayerID);
        if (prayer.Count == 0)
            // no matching record found, return false
            return false;
        wuoi.PrayerRow prayerItem = prayer[0];

        prayerItem.DateCreate = dateCreate;
        if (prayerContent == null) prayerItem.SetPrayerContentNull();
        else prayerItem.PrayerContent = prayerContent;

        // Add the new prayer item
        int rowsAffected = Adapter.Update(prayerItem);

        // Return true if precisely one row was inserted,
        // otherwise false
        return rowsAffected == 1;
    }


    /// <summary>
    /// Insert the prayer item
    /// </summary>
    /// <param name="dateCreate"></param>
    /// <param name="prayerContent"></param>
    /// <returns></returns>

    [System.ComponentModel.DataObjectMethodAttribute
(System.ComponentModel.DataObjectMethodType.Insert, true)]
    public bool AddPrayer(string dateCreate, string prayerContent)
    {
        // Create a new PrayerRow instance
        wuoi.PrayerDataTable prayer = new wuoi.PrayerDataTable();
        wuoi.PrayerRow prayerItem = prayer.NewPrayerRow();

        prayerItem.DateCreate = dateCreate;
        if (prayerContent == null) prayerItem.SetPrayerContentNull();
        else prayerItem.PrayerContent = prayerContent;

        // Add the new prayer item
        prayer.AddPrayerRow(prayerItem);
        int rowsAffected = Adapter.Update(prayerItem);

        // Return true if precisely one row was inserted,
        // otherwise false
        return rowsAffected == 1;
    }

    /// <summary>
    /// Delete the prayer item
    /// </summary>
    /// <param name="prayerID"></param>
    /// <returns></returns>

    [System.ComponentModel.DataObjectMethodAttribute
(System.ComponentModel.DataObjectMethodType.Delete, true)]
    public bool DeletePrayer(int prayerID)
    {
        int rowsAffected = Adapter.Delete(prayerID);

        // Return true if precisely one row was deleted,
        // otherwise false
        return rowsAffected == 1;
    }
}


My problem is no overload for method 'Delete' takes 1 argument. I have already given the prayerID as argument passing to the method. Why still have error?

This post has been edited by Sergio Tapia: 07 February 2011 - 07:20 AM
Reason for edit:: USE CODE TAGS!


Is This A Good Question/Topic? 0
  • +

Replies To: No overload for method 'Delete' takes '1' arguments

#2 CodingSup3rnatur@l-360  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 991
  • View blog
  • Posts: 971
  • Joined: 30-September 10

Re: No overload for method 'Delete' takes '1' arguments

Posted 07 February 2011 - 07:16 AM

The error is telling you that the method DOES NOT take 1 arguement. Therefore, your causing the error by passing it one arguement :)
Was This Post Helpful? 0
  • +
  • -

#3 Sergio Tapia  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1253
  • View blog
  • Posts: 4,168
  • Joined: 27-January 10

Re: No overload for method 'Delete' takes '1' arguments

Posted 07 February 2011 - 07:22 AM

The error is caused because PrayerTableAdapter.Delete() doesn't have a signature receiving 1 parameter. Check the signature for that method and see how many ingredients it needs before it can make the soup.

This post has been edited by Sergio Tapia: 07 February 2011 - 07:23 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1