首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

未能找到带参数的非泛型方法,该如何处理

2012-04-23 
未能找到带参数的非泛型方法逻辑层方法如下:[System.ComponentModel.DataObjectMethodAttribute(System.Co

未能找到带参数的非泛型方法
逻辑层方法如下:
  [System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Insert, true)]
  //public bool AddcalMainRecords(string? equipment_Name,int Use_Place_ID,DateTime Cal_Date,DateTime Due_Date,int Cal_Cycle_ID,string? Vender,string? Brand,string? Model,string? Serial_NO,string? Accuracy,string Class,int Project_ID,int Process_ID,string Status,string WI_NO,string? Drawing_NO,int? Renter_ID,DateTime? Rent_Date,int Sign_ID,string? Remark)
  public bool AddcalMainRecords(string equipment_Name, int Use_Place_ID, DateTime Cal_Date, DateTime Due_Date, int Cal_Cycle_ID, string Vender, string Brand, string Model, string Serial_NO, string Accuracy, string Class, int Project_ID, int Process_ID,string Status, string WI_NO, string Drawing_NO, int Renter_ID,DateTime Rent_Date,int Sign_ID,string Remark)

  {
  // 新建一个calMainRecordsRow实例
  cal.calMainRecordsDataTable mycals=new cal.calMainRecordsDataTable();
  cal.calMainRecordsRow mycal=mycals.NewcalMainRecordsRow();
  //mycal.Equipment_Name = equipment_Name;
  if (equipment_Name == null) mycal.SetEquipment_NameNull(); else mycal.Equipment_Name = equipment_Name;
  if (Vender == null) mycal.SetVenderNull(); else mycal.Vender = Vender;
  if (Brand == null) mycal.SetBrandNull(); else mycal.Brand = Brand;
  if (Model == null) mycal.SetModelNull(); else mycal.Equipment_Name = equipment_Name;
  if (Accuracy == null) mycal.SetAccuracyNull(); else mycal.Accuracy = Accuracy;
  if (Drawing_NO == null) mycal.SetDrawing_NONull(); else mycal.Drawing_NO = Drawing_NO;
  //少了Renter_ID和Rent_Date
  if (Remark == null) mycal.SetRemarkNull(); else mycal.Remark = Remark;
  mycals.AddcalMainRecordsRow(mycal);
  int rowsAffected = Adapter.Update(mycals);
  // 如果刚好新增了一条记录,则返回true,否则返回false
  return rowsAffected == 1;
  }
在表现层插入数据的时候,提示:“/WebSite2”应用程序中的服务器错误。
--------------------------------------------

ObjectDataSource“objGetDatas”未能找到带参数的非泛型方法“AddcalMainRecords”: Equipment_Name, Cal_Date, Due_Date, Vender, Brand, Model, Serial_NO, Accuracy, Class, Status, WI_NO, Drawing_NO, Remark, ID。 
说明: 执行当前 Web 请求期间,出现未经处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 

异常详细信息: System.InvalidOperationException: ObjectDataSource“objGetDatas”未能找到带参数的非泛型方法“AddcalMainRecords”: Equipment_Name, Cal_Date, Due_Date, Vender, Brand, Model, Serial_NO, Accuracy, Class, Status, WI_NO, Drawing_NO, Remark, ID。

源错误: 

执行当前 Web 请求期间生成了未经处理的异常。可以使用下面的异常堆栈跟踪信息确定有关异常原因和发生位置的信息。  

堆栈跟踪: 


[InvalidOperationException: ObjectDataSource“objGetDatas”未能找到带参数的非泛型方法“AddcalMainRecords”: Equipment_Name, Cal_Date, Due_Date, Vender, Brand, Model, Serial_NO, Accuracy, Class, Status, WI_NO, Drawing_NO, Remark, ID。]
  System.Web.UI.WebControls.ObjectDataSourceView.GetResolvedMethodData(Type type, String methodName, IDictionary allParameters, DataSourceOperation operation) +1356919
  System.Web.UI.WebControls.ObjectDataSourceView.ExecuteInsert(IDictionary values) +852
  System.Web.UI.DataSourceView.Insert(IDictionary values, DataSourceViewOperationCallback callback) +89
  System.Web.UI.WebControls.DetailsView.HandleInsert(String commandArg, Boolean causesValidation) +379
  System.Web.UI.WebControls.DetailsView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +574
  System.Web.UI.WebControls.DetailsView.OnBubbleEvent(Object source, EventArgs e) +95
  System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
  System.Web.UI.WebControls.DetailsViewRow.OnBubbleEvent(Object source, EventArgs e) +112


  System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
  System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +125
  System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +169
  System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +9
  System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
  System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +176
  System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563

 


--------------------------------------------
版本信息: Microsoft .NET Framework 版本:4.0.30319; ASP.NET 版本:4.0.30319.1

[解决办法]
ObjectDataSource执行你的AddcalMainRecords(....)
如果是双向绑定的话,(也就是默认状态时)
AddcalMainRecords中对数据字段的名称必须和数据表的名称相同!
仔细检查你的AddcalMainRecords(....)中的字段名!!
[解决办法]
看看看看ObjectDataSource的参数列表,是否与字段一致
[System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Insert, true)]
public bool AddProduct(string productName, int? supplierID, int...)
{

}

热点排行