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.BusinessLog icLayer
#Region "DAL Access"
Public Class States
Public Sub New()
End Sub
Public Shared Function GetAllStates() As DataTable
Using db As New dsStatesTableAd apters.statesTa bleAdapter
Return db.GetData()
End Using
End Function
Public Shared Sub InsertState(ByV al UsState As String, ByVal
UsStateAbbrevia tion As String)
Using db As New dsStatesTableAd apters.statesTa bleAdapter
db.Insert(UsSta te, UsStateAbbrevia tion)
End Using
End Sub
Public Shared Sub UpdateState(ByV al UsState As String, ByVal
UsStateAbbrevia tion As String, ByVal original_StateI d As Long)
Using db As New dsStatesTableAd apters.statesTa bleAdapter
db.Update(UsSta te, UsStateAbbrevia tion, original_StateI d)
End Using
End Sub
Public Shared Sub DeleteState(ByV al Original_StateI d As Long)
Using db As New dsStatesTableAd apters.statesTa bleAdapter
db.Delete(Origi nal_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...
ObjectDataSourc e 'ObjectDataSour ce1' could not find a non-generic method
'InsertState' that has parameters: UsState, UsStateAbbrevia tion, 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.InvalidO perationExcepti on: ObjectDataSourc e
'ObjectDataSour ce1' could not find a non-generic method 'InsertState' that
has parameters: UsState, UsStateAbbrevia tion, 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="S tateId"
DataSourceID="O bjectDataSource 1">
<Columns>
<asp:CommandFie ld ShowDeleteButto n="True" ShowEditButton= "True"
ShowSelectButto n="True" />
</Columns>
</asp:GridView>
<asp:ObjectData Source ID="ObjectDataS ource1" runat="server"
DeleteMethod="D eleteState" InsertMethod="I nsertState"
OldValuesParame terFormatString ="original_{ 0}"
SelectMethod="G etAllStates"
TypeName="Zzz.B usinessLogicLay er.States" UpdateMethod="U pdateState">
<DeleteParamete rs>
<asp:Paramete r Name="Original_ StateId" Type="Int64" />
</DeleteParameter s>
<UpdateParamete rs>
<asp:Paramete r Name="UsState" Type="String" />
<asp:Paramete r Name="UsStateAb breviation" Type="String" />
<asp:Paramete r Name="original_ StateId" Type="Int64" />
</UpdateParameter s>
<InsertParamete rs>
<asp:Paramete r Name="UsState" Type="String" />
<asp:Paramete r Name="UsStateAb breviation" Type="String" />
</InsertParameter s>
</asp:ObjectDataS ource>
<asp:DetailsVie w ID="DetailsView 1" runat="server" DataKeyNames="S tateId"
DataSourceID="O bjectDataSource 1" DefaultMode="In sert" Height="50px"
Width="125px">
<Fields>
<asp:CommandFie ld ShowInsertButto n="True" />
</Fields>
</asp:DetailsView >
Any ideas what I'm doing wrong???
Thanks...
Trying to use a tiered methodology I called the functions from my BLL.
Namespace Zzz.BusinessLog icLayer
#Region "DAL Access"
Public Class States
Public Sub New()
End Sub
Public Shared Function GetAllStates() As DataTable
Using db As New dsStatesTableAd apters.statesTa bleAdapter
Return db.GetData()
End Using
End Function
Public Shared Sub InsertState(ByV al UsState As String, ByVal
UsStateAbbrevia tion As String)
Using db As New dsStatesTableAd apters.statesTa bleAdapter
db.Insert(UsSta te, UsStateAbbrevia tion)
End Using
End Sub
Public Shared Sub UpdateState(ByV al UsState As String, ByVal
UsStateAbbrevia tion As String, ByVal original_StateI d As Long)
Using db As New dsStatesTableAd apters.statesTa bleAdapter
db.Update(UsSta te, UsStateAbbrevia tion, original_StateI d)
End Using
End Sub
Public Shared Sub DeleteState(ByV al Original_StateI d As Long)
Using db As New dsStatesTableAd apters.statesTa bleAdapter
db.Delete(Origi nal_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...
ObjectDataSourc e 'ObjectDataSour ce1' could not find a non-generic method
'InsertState' that has parameters: UsState, UsStateAbbrevia tion, 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.InvalidO perationExcepti on: ObjectDataSourc e
'ObjectDataSour ce1' could not find a non-generic method 'InsertState' that
has parameters: UsState, UsStateAbbrevia tion, 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="S tateId"
DataSourceID="O bjectDataSource 1">
<Columns>
<asp:CommandFie ld ShowDeleteButto n="True" ShowEditButton= "True"
ShowSelectButto n="True" />
</Columns>
</asp:GridView>
<asp:ObjectData Source ID="ObjectDataS ource1" runat="server"
DeleteMethod="D eleteState" InsertMethod="I nsertState"
OldValuesParame terFormatString ="original_{ 0}"
SelectMethod="G etAllStates"
TypeName="Zzz.B usinessLogicLay er.States" UpdateMethod="U pdateState">
<DeleteParamete rs>
<asp:Paramete r Name="Original_ StateId" Type="Int64" />
</DeleteParameter s>
<UpdateParamete rs>
<asp:Paramete r Name="UsState" Type="String" />
<asp:Paramete r Name="UsStateAb breviation" Type="String" />
<asp:Paramete r Name="original_ StateId" Type="Int64" />
</UpdateParameter s>
<InsertParamete rs>
<asp:Paramete r Name="UsState" Type="String" />
<asp:Paramete r Name="UsStateAb breviation" Type="String" />
</InsertParameter s>
</asp:ObjectDataS ource>
<asp:DetailsVie w ID="DetailsView 1" runat="server" DataKeyNames="S tateId"
DataSourceID="O bjectDataSource 1" DefaultMode="In sert" Height="50px"
Width="125px">
<Fields>
<asp:CommandFie ld ShowInsertButto n="True" />
</Fields>
</asp:DetailsView >
Any ideas what I'm doing wrong???
Thanks...