I'm working on a basic ASP.NET web form that uses an ObjectDataSource to insert data into a database. Originally, it was scripted using a SQLDataSource (with the required code behind) and worked like a charm. Since the rest of the site uses an XSD and ObjectDataSources, I'm trying to convert it to an ObjectDataSource. After all of the required coding, during testing, I'm recieving the error:
ObjectDataSource 'odsRequest' could not find a non-generic method 'InsertRequest' that has parameters: wrName, customerID, staffID, priority, status, genCom, submitDt, targetDt, wrType, @WRName, @CustomerID, @StaffID, @Priority, @Status, @GenCom, @SubmitDt, @TargetDt, @WRType.
I've encountered simular issues in the past and have been able to quickly fix them. I've spent a couple hours looking at this and am stumped.
Here are the various sections of code I am using:
SQL QUERY
INSERT INTO WorkReq (WRName, CustomerID, StaffID, Priority, Status, GenCom, SubmitDt, TargetDt, WRType)
VALUES (@WRName, @CustomerID, @StaffID, @Priority, @Status, @GenCom, @SubmitDt, @TargetDt, @WRType);
SELECT SCOPE_IDENTITY();
ASP ObjectDataSource
<asp:ObjectDataSource ID="odsRequest" runat="server"
InsertMethod="InsertRequest" TypeName="WorkReqBLL">
<InsertParameters>
<asp:Parameter Name="wrName" Type="String" />
<asp:Parameter Name="customerID" Type="Int32" />
<asp:Parameter Name="staffID" Type="Int32" />
<asp:Parameter Name="priority" Type="String" />
<asp:Parameter Name="status" Type="String" />
<asp:Parameter Name="genCom" Type="String" />
<asp:Parameter Name="submitDt" Type="DateTime" />
<asp:Parameter Name="targetDt" Type="DateTime" />
<asp:Parameter Name="wrType" Type="String" />
</InsertParameters>
</asp:ObjectDataSource>
VB Code Behind
Protected Sub odsRequest_Inserting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ObjectDataSourceMethodEventArgs) Handles odsRequest.Inserting
If ddlCourse.SelectedValue = 0 Then
e.InputParameters("@WRName") = txtSummary.Text
Else
e.InputParameters("@WRName") = txtSummary.Text & " - " & ddlCourse.SelectedItem.Text
End If
e.InputParameters("@CustomerID") = GetUserID()
e.InputParameters("@StaffID") = "35000"
e.InputParameters("@Priority") = "Medium"
e.InputParameters("@Status") = "O"
e.InputParameters("@GenCom") = txtExplanation.Text.Replace(Environment.NewLine, vbNewLine)
e.InputParameters("@SubmitDt") = DateTime.Now
e.InputParameters("@TargetDt") = DateTime.ParseExact(txtTarget.Text & " 08:00 AM", "MM/dd/yyyy HH:mm tt", Nothing)
e.InputParameters("@WRType") = "External"
End Sub
VB BLL
<System.ComponentModel.DataObjectMethodAttribute _
(System.ComponentModel.DataObjectMethodType.Insert, False)> _
Public Function InsertRequest( _
ByVal wrName As String, _
ByVal customerID As Nullable(Of Integer), _
ByVal staffID As Nullable(Of Integer), _
ByVal priority As String, _
ByVal status As String, _
ByVal genCom As String, _
ByVal submitDt As Nullable(Of Date), _
ByVal targetDt As Nullable(Of Date), _
ByVal wrType As String) As Boolean
Dim requests As New ITEX.WorkReqDataTable()
Dim request As ITEX.WorkReqRow = requests.NewWorkReqRow()
request.WrName = wrName
request.Priority = priority
request.Status = status
If Not customerID.HasValue Or customerID.Value = 0 Then
request.SetCustomerIDNull()
Else
request.CustomerID = customerID.Value
End If
If Not staffID.HasValue Or staffID.Value = 0 Then
request.SetStaffIDNull()
Else
request.StaffID = staffID.Value
End If
request.SubmitDt = submitDt.Value
If Not targetDt.HasValue Then
request.SetTargetDtNull()
Else
request.TargetDt = targetDt.Value
End If
request.WrType = wrType
requests.AddWorkReqRow(request)
Dim rowsAffected As Integer = Adapter.Update(requests)
Return rowsAffected = 1
End Function