ObjectDataSource'ObjectDataSource1'找不到非泛型方法Update [英] ObjectDataSource 'ObjectDataSource1' could not find a non-generic method Update

查看:178
本文介绍了ObjectDataSource'ObjectDataSource1'找不到非泛型方法Update的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

到目前为止,我尝试了每个解决方案,并且每次都遇到这个类似的问题。
Plz Help !!

静态方法

  [ DataObjectMethod(DataObjectMethodType.Update)] 
public static void updateCustomer(int CustomerName,string firstname,string lastname,string email,int AccountNum)
{

SqlConnection connection = new SqlConnection( getConnectionString());

connection.Open();

SqlCommand command = new SqlCommand(sp_updateCustomer,connection);
command.CommandType = CommandType.StoredProcedure;
command.Parameters.AddWithValue(@ Cust_Id,CustomerID);
command.Parameters.AddWithValue(@ Cust_Fname,firstname);
command.Parameters.AddWithValue(@ Cust_Lname,lastname);
command.Parameters.AddWithValue(@ Cust_Email,email);
command.Parameters.AddWithValue(@ Bank_Account_num,AccountNum);




command.ExecuteNonQuery();

connection.Close();
}

GridView
















pre $ lt; code>< asp:ObjectDataSource ID =ObjectDataSource1runat =serverOldValuesParameterFormatString =original_ {0}SelectMethod =viewAllCustomerTypeName =BusinessLogicUpdateMethod =updateCustomer>
< UpdateParameters>
< asp:Parameter Name =CustomerIDType =Int32/>
< asp:Parameter Name =firstnameType =String/>
< asp:Parameter Name =lastnameType =String/>
< asp:Parameter Name =emailType =String/>
< asp:Parameter Name =AccountNumType =Int32/>
< / UpdateParameters>


解决方案

使用VS-2012 Express for WEB,我也遇到了这个问题,并发现参数名称必须匹配四个地方 - typed-data-set designer(xsd),BLL-class update-function, aspx-designer设置为配置数据源和aspx源文件。

首先,通过选择将异常详细信息复制到剪贴板弹出错误消息,保存错误消息的副本,以便在NOTEPAD中引用它。查看这些参数为错误:
请注意,当被两个*包围时, EMAIL 参数应该为BOLD。

  Message = ObjectDataSource'ODS_LOGIN_DETAILS'找不到具有参数的非泛型方法
'UpdateFromDetailsView':
original_UID_LOGIN,original_UID_CONTACT,UID_USER_TYPE,TXT_USERNAME,
TXT_PASSWORD,BOOL_IS_ACTIVE ,DT_END,cFirstName,cLastName,
cCONTACTTITLE,original_cTXT_PHONE,** cCONTACT_EMAIL **。

然后,将错误消息中的参数列表与代码中的这些位置进行比较: p>


  1. 数据源参数的aspx页面(例如...)

     < UpdateParameters> 
    < asp:Parameter Name =original_UID_LOGINType =Int32/>
    < asp:Parameter Name =original_UID_CONTACTType =Int32/>
    < asp:Parameter Name =UID_USER_TYPEType =Int32/>
    < asp:Parameter Name =TXT_USERNAMEType =String/>
    < asp:Parameter Name =TXT_PASSWORDType =String/>
    < asp:Parameter Name =BOOL_IS_ACTIVEType =Boolean/>
    < asp:参数名称=DT_ENDType =DateTime/>
    < asp:Parameter Name =cFirstNameType =String/>
    < asp:Parameter Name =cLastNameType =String/>
    < asp:Parameter Name =cCONTACTTITLEType =String/>
    < asp:Parameter Name =original_cTXT_PHONEType =String/>
    < asp:Parameter Name =** cCONTACT_EMAIL **Type =String/>


现在比较ObjectDataSource UPDATE-method的参数列表:

  Public Function UpdateFromDetailsView(
ByVal original_UID_LOGIN作为Int32,
ByVal original_UID_CONTACT作为Int32,
ByVal UID_USER_TYPE作为Int32,
ByVal TXT_USERNAME作为字符串,
ByVal TXT_PASSWORD作为字符串,
ByVal BOOL_IS_ACTIVE作为布尔值,
ByVal DT_END As Date,
ByVal cFirstName As String,
ByVal cLastName As String,
ByVal cCONTACTTITLE As String,
ByVal original_cTXT_PHONE As String,
ByVal ** CONTACT_EMAIL **作为字符串
)作为布尔

最后,比较参数到强类型数据集函数:

  iRet = Adapter.UpdateFromDetailsView(
original_UID_LOGIN,
original_UID_CONTACT ,
UID_USER_TYPE,
TXT_USERNAME,
TXT_PASSWORD,
BOOL_IS_ACTIVE,
DT_END,
cFirstName,
cLastName,
cCONTACTTITLE,
original_cTXT_PHONE,
** CONTACT_EMAIL **)

您应该注意到EMAIL参数存在许多差异,并且所有这些引用都需要具有相同的参数名称。



当您重新构建解决方案时,类型化数据集将被更新,并且BLL类将被更新,但不是aspx中的ObjectDataSource。在重新构建解决方案后,您需要在aspx-designer页面上配置数据源。



在此示例中,BLL类需要包含'cCONTACT_EMAIL'作为参数并传递给适配器函数。

我希望这有助于...谢谢... John


i tried every solution so far with this similar problem and i get this error everytime. Plz Help!!

static method

[DataObjectMethod(DataObjectMethodType.Update)]
public static void updateCustomer(int CustomerID, string firstname, string lastname, string email, int AccountNum)
{

    SqlConnection connection = new SqlConnection(getConnectionString());

    connection.Open();

    SqlCommand command = new SqlCommand("sp_updateCustomer", connection);
    command.CommandType = CommandType.StoredProcedure;
    command.Parameters.AddWithValue("@Cust_Id", CustomerID);
    command.Parameters.AddWithValue("@Cust_Fname", firstname);
    command.Parameters.AddWithValue("@Cust_Lname", lastname);
    command.Parameters.AddWithValue("@Cust_Email", email);
    command.Parameters.AddWithValue("@Bank_Account_num", AccountNum);




    command.ExecuteNonQuery();

    connection.Close();
}

GridView

<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" OldValuesParameterFormatString="original_{0}" SelectMethod="viewAllCustomer" TypeName="BusinessLogic" UpdateMethod="updateCustomer" >
    <UpdateParameters>
        <asp:Parameter Name="CustomerID" Type="Int32" />
        <asp:Parameter Name="firstname" Type="String" />
        <asp:Parameter Name="lastname" Type="String" />
        <asp:Parameter Name="email" Type="String" />
        <asp:Parameter Name="AccountNum" Type="Int32" />
    </UpdateParameters>

解决方案

Using VS-2012 Express for WEB, I struggled with this too, and have found that there are four places that the parameter names must match - typed-data-set designer (xsd), BLL-class update-function, aspx-designer to 'Configure Data Source' and the aspx-source file.

First, save a copy of the error message when the error popups up by selecting "Copy exception detail to the clipboard" so you can refer to it in NOTEPAD. See these parameters as the error: Notice that the EMAIL parameter should be BOLD when surrounded by two *.

  Message=ObjectDataSource 'ODS_LOGIN_DETAILS' could not find a non-generic method 
'UpdateFromDetailsView' that has parameters: 
    original_UID_LOGIN, original_UID_CONTACT, UID_USER_TYPE, TXT_USERNAME,
    TXT_PASSWORD, BOOL_IS_ACTIVE, DT_END, cFirstName, cLastName, 
    cCONTACTTITLE, original_cTXT_PHONE, **cCONTACT_EMAIL**.

Then, compare the list of parameters in the error-message to these locations in your code:

  1. The aspx page of the datasource parameters (eg...)

    <UpdateParameters>
    <asp:Parameter Name="original_UID_LOGIN" Type="Int32" />
    <asp:Parameter Name="original_UID_CONTACT" Type="Int32" />
    <asp:Parameter Name="UID_USER_TYPE" Type="Int32" />
    <asp:Parameter Name="TXT_USERNAME" Type="String" />
    <asp:Parameter Name="TXT_PASSWORD" Type="String" />
    <asp:Parameter Name="BOOL_IS_ACTIVE" Type="Boolean" />
    <asp:Parameter Name="DT_END" Type="DateTime" />
    <asp:Parameter Name="cFirstName" Type="String" />
    <asp:Parameter Name="cLastName" Type="String" />
    <asp:Parameter Name="cCONTACTTITLE" Type="String" />
    <asp:Parameter Name="original_cTXT_PHONE" Type="String" />
    <asp:Parameter Name="**cCONTACT_EMAIL**" Type="String" />
    

Now compare the parameter list of the ObjectDataSource UPDATE-method:

Public Function UpdateFromDetailsView(
   ByVal original_UID_LOGIN As Int32,
   ByVal original_UID_CONTACT As Int32,
   ByVal UID_USER_TYPE As Int32,
   ByVal TXT_USERNAME As String,
   ByVal TXT_PASSWORD As String,
   ByVal BOOL_IS_ACTIVE As Boolean,
   ByVal DT_END As Date,
   ByVal cFirstName As String,
   ByVal cLastName As String,
   ByVal cCONTACTTITLE As String,
   ByVal original_cTXT_PHONE As String,
   ByVal **CONTACT_EMAIL** As String
 ) As Boolean

And, finally, compare the parameters to the strongly-typed-dataset function:

iRet = Adapter.UpdateFromDetailsView(
   original_UID_LOGIN,
   original_UID_CONTACT,
   UID_USER_TYPE,
   TXT_USERNAME,
   TXT_PASSWORD,
   BOOL_IS_ACTIVE,
   DT_END,
   cFirstName,
   cLastName,
   cCONTACTTITLE,
   original_cTXT_PHONE,
   **CONTACT_EMAIL**)

You should notice that there are a number of differences for the EMAIL parameter, and ALL of these references need to have the same parameter-name.

When you "Rebuild Solution", the typed-data-set will be updated, and the BLL-class will be updated, but NOT the ObjectDataSource in the aspx. You would need to "Configure Data Source" on the aspx-designer page after rebuilding the solution.

In this example, the BLL-class needed to contain a 'cCONTACT_EMAIL' as the parameter and passed to the adapter function.

I hope this helps...thanks...John

这篇关于ObjectDataSource'ObjectDataSource1'找不到非泛型方法Update的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆