By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,650 Members | 1,865 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,650 IT Pros & Developers. It's quick & easy.

Error: ObjectDataSource 'ObjectDataSource1' could not find a non-generic method 'InsertState' that has parameters: UsState, UsStateAbbreviation, StateId.

P: n/a
Using Visual Studio I created a DataSet using the GUI (XSD file).

Trying to use a tiered methodology I called the functions from my BLL.

Namespace Zzz.BusinessLogicLayer
#Region "DAL Access"
Public Class States
Public Sub New()
End Sub

Public Shared Function GetAllStates() As DataTable
Using db As New dsStatesTableAdapters.statesTableAdapter
Return db.GetData()
End Using
End Function

Public Shared Sub InsertState(ByVal UsState As String, ByVal
UsStateAbbreviation As String)
Using db As New dsStatesTableAdapters.statesTableAdapter
db.Insert(UsState, UsStateAbbreviation)
End Using
End Sub

Public Shared Sub UpdateState(ByVal UsState As String, ByVal
UsStateAbbreviation As String, ByVal original_StateId As Long)
Using db As New dsStatesTableAdapters.statesTableAdapter
db.Update(UsState, UsStateAbbreviation, original_StateId)
End Using
End Sub

Public Shared Sub DeleteState(ByVal Original_StateId As Long)
Using db As New dsStatesTableAdapters.statesTableAdapter
db.Delete(Original_StateId)
End Using
End Sub
End Class
#End Region
End Namespace
I got the default Select, Update, and Delete working, but the Insert keeps
giving me this error...

ObjectDataSource 'ObjectDataSource1' could not find a non-generic method
'InsertState' that has parameters: UsState, UsStateAbbreviation, StateId.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: ObjectDataSource
'ObjectDataSource1' could not find a non-generic method 'InsertState' that
has parameters: UsState, UsStateAbbreviation, StateId.
I'm using a DetailsView to insert the records. Here's the simple layout of
my form...
<asp:GridView ID="GridView1" runat="server" DataKeyNames="StateId"
DataSourceID="ObjectDataSource1">
<Columns>
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True"
ShowSelectButton="True" />
</Columns>
</asp:GridView>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
DeleteMethod="DeleteState" InsertMethod="InsertState"
OldValuesParameterFormatString="original_{0}"
SelectMethod="GetAllStates"
TypeName="Zzz.BusinessLogicLayer.States" UpdateMethod="UpdateState">
<DeleteParameters>
<asp:Parameter Name="Original_StateId" Type="Int64" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="UsState" Type="String" />
<asp:Parameter Name="UsStateAbbreviation" Type="String" />
<asp:Parameter Name="original_StateId" Type="Int64" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="UsState" Type="String" />
<asp:Parameter Name="UsStateAbbreviation" Type="String" />
</InsertParameters>
</asp:ObjectDataSource>
<asp:DetailsView ID="DetailsView1" runat="server" DataKeyNames="StateId"
DataSourceID="ObjectDataSource1" DefaultMode="Insert" Height="50px"
Width="125px">
<Fields>
<asp:CommandField ShowInsertButton="True" />
</Fields>
</asp:DetailsView>
Any ideas what I'm doing wrong???

Thanks...
Sep 16 '08 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.