Jialiang,
I remove the "Original" word from my code and changed Vendor_ID As Integer
to Int32
Still same issue, Here are the code (vb and aspx)
***VendorDB.vb***
Imports Microsoft.VisualBasic
Imports System.ComponentModel
Imports System.Data
Imports System.Data.SqlClient
Imports System.Collections.Generic
<DataObject(True)> _
Public Class VendorDB
Const conString As String = "Data Source=(local);Initial
Catalog=Catalog;User ID=xxxxxx;Password=xxxxxx"
Public Shared Function GetVendor() As SqlDataReader
Dim con As New SqlConnection(conString)
Dim selectString As String = "SELECT * From Vendor"
Dim cmd As New SqlCommand(selectString, con)
con.Open()
Dim dtr As SqlDataReader =
cmd.ExecuteReader(CommandBehavior.CloseConnection)
Return dtr
End Function
Public Function InsertVendor(ByVal Vendor_ID As Int32, _
ByVal Vendor_Name As String, _
ByVal Address1 As String, _
ByVal Address2 As String, _
ByVal City As String, _
ByVal State As String, _
ByVal Zip As String, _
ByVal Phone As String, _
ByVal Fax As String, _
ByVal Email As String, _
ByVal CrtdUser As String, _
ByVal URL As String) As Integer
Dim con As New SqlConnection(conString)
Dim cmd As SqlCommand = New SqlCommand("INSERT INTO Vendor
(Vendor_Name, Address1, Address2, City, State, Zip, Phone, Fax, Email,
CrtdUser, URL) " & _
" Values( [at] Vendor_Name, [at] Address1, [at] Address2, [at] City, [at] State, [at] zip,
[at] Phone, [at] Fax, [at] Email, [at] CrtdUser, [at] URL))")
cmd.Parameters.Add(" [at] Vendor_Name", SqlDbType.VarChar, 50).Value =
Vendor_Name
cmd.Parameters.Add(" [at] Address1", SqlDbType.VarChar, 50).Value =
Address1
cmd.Parameters.Add(" [at] Address2", SqlDbType.VarChar, 50).Value =
Address2
cmd.Parameters.Add(" [at] City", SqlDbType.VarChar, 50).Value = City
cmd.Parameters.Add(" [at] State", SqlDbType.VarChar, 50).Value = State
cmd.Parameters.Add(" [at] Zip", SqlDbType.VarChar, 50).Value = Zip
cmd.Parameters.Add(" [at] Phone", SqlDbType.VarChar, 50).Value = Phone
cmd.Parameters.Add(" [at] Fax", SqlDbType.VarChar, 50).Value = Fax
cmd.Parameters.Add(" [at] Email", SqlDbType.VarChar, 50).Value = Email
cmd.Parameters.Add(" [at] CrtdUser", SqlDbType.VarChar, 50).Value =
CrtdUser
cmd.Parameters.Add(" [at] URL", SqlDbType.VarChar, 50).Value = URL
Dim p As SqlParameter = cmd.Parameters.Add(" [at] Vendor_ID",
SqlDbType.Int)
p.Direction = ParameterDirection.Output
Dim newEmployeeID As Integer = 0
Try
con.Open()
cmd.ExecuteNonQuery()
newEmployeeID = CInt(p.Value)
Catch e As SqlException
e.ErrorCode.ToString()
Finally
con.Close()
End Try
Return newEmployeeID
End Function
Public Shared Sub UpdateProduct(ByVal Vendor_ID As Int32, _
ByVal Vendor_Name As String, _
ByVal Address1 As String, _
ByVal Address2 As String, _
ByVal City As String, _
ByVal State As String, _
ByVal Zip As String, _
ByVal Phone As String, _
ByVal Fax As String, _
ByVal Email As String, _
ByVal CrtdUser As String, _
ByVal URL As String)
Dim con As New SqlConnection(conString)
Dim updateString As String = "UPDATE Vendor SET
Vendor_Name= [at] Vendor_Name,Address1= [at] Address1, Address2= [at] Address2, City= [at] City,
State= [at] State, Zip= [at] Zip, Phone= [at] Phone, Fax= [at] Fax, Email= [at] Email,
CrtdUser= [at] CrtdUser, URL= [at] URL WHERE Vendor_ID= [at] Vendor_ID"
Dim cmd As New SqlCommand(updateString, con)
cmd.Parameters.AddWithValue(" [at] Vendor_Name", Vendor_Name)
cmd.Parameters.AddWithValue(" [at] Address1", Address1)
cmd.Parameters.AddWithValue(" [at] Address2", Address1)
cmd.Parameters.AddWithValue(" [at] City", City)
cmd.Parameters.AddWithValue(" [at] State", State)
cmd.Parameters.AddWithValue(" [at] Zip", Zip)
cmd.Parameters.AddWithValue(" [at] Phone", Phone)
cmd.Parameters.AddWithValue(" [at] Fax", Fax)
cmd.Parameters.AddWithValue(" [at] Email", Email)
cmd.Parameters.AddWithValue(" [at] Crtd", CrtdUser)
cmd.Parameters.AddWithValue(" [at] URL", URL)
cmd.Parameters.AddWithValue(" [at] Vendor_ID", Vendor_ID)
Try
con.Open()
cmd.ExecuteNonQuery()
Catch ex As SqlException
Throw ex
Finally
con.Close()
End Try
End Sub
Public Shared Sub DeleteVendor(ByVal Vendor_ID As Integer)
Dim con As New SqlConnection(conString)
Dim deleteString As String = "DELETE Vendor " & _
"WHERE Vendor_ID= [at] Vendor_ID"
Dim cmd As New SqlCommand(deleteString, con)
cmd.Parameters.AddWithValue(" [at] Vendor_ID", Vendor_ID)
Try
con.Open()
cmd.ExecuteNonQuery()
Catch ex As SqlException
Throw ex
Finally
con.Close()
End Try
End Sub
End Class
*****Here is the aspx page******
<% [at] Page Language="VB" AutoEventWireup="false" CodeFile="Default2.aspx.vb"
Inherits="Default2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Vendor</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
DeleteMethod="DeleteVendor"
InsertMethod="InsertVendor" SelectMethod="GetVendor"
TypeName="VendorDB" UpdateMethod="UpdateProduct">
<DeleteParameters>
<asp:Parameter Name="Vendor_ID" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="Vendor_ID" Type="Int32" />
<asp:Parameter Name="Vendor_Name" Type="String" />
<asp:Parameter Name="Address1" Type="String" />
<asp:Parameter Name="Address2" Type="String" />
<asp:Parameter Name="City" Type="String" />
<asp:Parameter Name="State" Type="String" />
<asp:Parameter Name="Zip" Type="String" />
<asp:Parameter Name="Phone" Type="String" />
<asp:Parameter Name="Fax" Type="String" />
<asp:Parameter Name="Email" Type="String" />
<asp:Parameter Name="CrtdUser" Type="String" />
<asp:Parameter Name="URL" Type="String" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="Vendor_ID" Type="String" />
<asp:Parameter Name="Vendor_Name" Type="String" />
<asp:Parameter Name="Address1" Type="String" />
<asp:Parameter Name="Address2" Type="String" />
<asp:Parameter Name="City" Type="String" />
<asp:Parameter Name="State" Type="String" />
<asp:Parameter Name="Zip" Type="String" />
<asp:Parameter Name="Phone" Type="String" />
<asp:Parameter Name="Fax" Type="String" />
<asp:Parameter Name="Email" Type="String" />
<asp:Parameter Name="CrtdUser" Type="String" />
<asp:Parameter Name="URL" Type="String" />
</InsertParameters>
</asp:ObjectDataSource>
</div>
<asp:GridView ID="GridView1" runat="server" CellPadding="4"
DataSourceID="ObjectDataSource1"
Font-Names="Verdana" Font-Size="8pt" ForeColor="#333333"
GridLines="None">
<FooterStyle BackColor="#5D7B9D" Font-Bold="True"
ForeColor="White" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<Columns>
<asp:CommandField ShowEditButton="True"
ShowSelectButton="True" ButtonType="Button" ShowDeleteButton="True" />
</Columns>
<PagerStyle BackColor="#284775" ForeColor="White"
HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True"
ForeColor="#333333" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True"
ForeColor="White" />
<EditRowStyle BackColor="#999999" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
</asp:GridView>
<asp:DetailsView ID="DetailsView1" runat="server" CellPadding="4"
DataSourceID="ObjectDataSource1"
DefaultMode="Insert" ForeColor="#333333" GridLines="None"
Height="50px" Width="125px" Font-Names="Verdana" Font-Size="8pt">
<FooterStyle BackColor="#5D7B9D" Font-Bold="True"
ForeColor="White" />
<CommandRowStyle BackColor="#E2DED6" Font-Bold="True" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<FieldHeaderStyle BackColor="#E9ECF1" Font-Bold="True" />
<PagerStyle BackColor="#284775" ForeColor="White"
HorizontalAlign="Center" />
<Fields>
<asp:CommandField ButtonType="Button"
ShowInsertButton="True" />
</Fields>
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True"
ForeColor="White" />
<EditRowStyle BackColor="#999999" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
</asp:DetailsView>
</form>
</body>
</html>
Thnaks
Ed Dror
"Jialiang Ge [MSFT]" <jialge [at] online.microsoft.com> wrote in message
news:j71QnJ$jIHA.4200 [at] TK2MSFTNGHUB02.phx.gbl...
> Hello Ed,
>
> The ASP.NET error "could not find a non-generic method" caused by naming
> rules between OldValuesParameterFormatString and update function Parameter
> name is a very common problem. There can be various workarounds for
> different scenarios. For example:
>
> http://aspadvice.com/blogs/ssmith/archive/2007/02/17/ObjectD ataSource-could-
> not-find-a-non_2D00_generic-method-Update-Error.aspx
> https://connect.microsoft.com/VisualStudio/feedback/ViewFeed back.aspx?Feedba
> ckID=260674
> http://weblogs.asp.net/bradygaster/archive/2006/09/26/How-to -Bloody-Your-For
> ehead.aspx
> http://geekswithblogs.net/mnf/archive/2006/08/30/89734.aspx
> http://forums.asp.net/t/969187.aspx
> http://msdn2.microsoft.com/en-us/library/bb332382.aspx
>
> But based on my observation of your sample code, a possible quick
> resolution is:
>
> Step1. Change the first parameter name of UpdateProduct from
> original_Vendor_ID to Vendor_ID (I assume Vendor_ID is in your GridView's
> DataKeyNames property), and update the code inside UpdateProduct
> accordingly.
>
> Step2. Change the parameter name defined in your ObjectDataSource from
> original_Vendor_ID to Vendor_ID:
> <UpdateParameters>
> <asp:Parameter Name=" Vendor_ID" Type="Int32" />
> ˇ.. (other parameters)
> </UpdateParameters>
>
> Step3. Compile the project and try the update again.
>
> If this resolution does not help, please paste your aspx code of the
> GridView here, I need to see how you defined the DataKeyNames property.
> You
> may also try other workarounds mentioned in the above links for you
> specific scenario.
>
> Regards,
> Jialiang Ge (jialge [at] online.microsoft.com, remove 'online.')
> Microsoft Online Community Support
>
> Delighting our customers is our #1 priority. We welcome your comments and
> suggestions about how we can improve the support we provide to you. Please
> feel free to let my manager know what you think of the level of service
> provided. You can send feedback directly to my manager at:
> msdnmg [at] microsoft.com.
>
> ==================================================
> Get notification to my posts through email? Please refer to
> http://msdn.microsoft.com/subscriptions/managednewsgroups/de fault.aspx#notif
> ications.
>
> Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
> where an initial response from the community or a Microsoft Support
> Engineer within 1 business day is acceptable. Please note that each follow
> up response may take approximately 2 business days as the support
> professional working with you may need further investigation to reach the
> most efficient resolution. The offering is not appropriate for situations
> that require urgent, real-time or phone-based interactions or complex
> project analysis and dump analysis issues. Issues of this nature are best
> handled working with a dedicated Microsoft Support Engineer by contacting
> Microsoft Customer Support Services (CSS) at
> http://msdn.microsoft.com/subscriptions/support/default.aspx .
> ==================================================
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>
