【发布时间】:2014-04-14 07:27:59
【问题描述】:
到目前为止,我尝试了所有类似问题的解决方案,但每次都收到此错误。 请帮忙!!
静态方法
[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();
}
网格视图
<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>
【问题讨论】:
-
你在哪里声明
updateCustomer? -
你能给我们展示一下整个类结构以及命名空间和selectmethod和updatemethod吗?
-
确保你的类名和命名空间
标签: c# asp.net gridview objectdatasource