Note that there are some explanatory texts on larger screens.

plurals
  1. POSQLException was unhandled, Dataset -Table Adapter
    text
    copied!<p>I have the following stored procedure and I'm calling it from my Windows Forms application DataSet like this: </p> <pre><code> Me.TransactionTableAdapter.spPaymentApply(130, iAmount, Now) </code></pre> <p>Although I provide the CustomerID, (and stepping in the code to see if it's actually there - and it is) I get the following error during execution: Procedure or function 'PaymentApply' expects parameter '@CustomerID', which was not supplied.</p> <p>Here is my SP:</p> <pre><code>USE [dbPB] GO /****** Object: StoredProcedure [dbo].[PaymentApply] Script Date: 05/30/2013 18:34:01 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER PROCEDURE [dbo].[PaymentApply] @CustomerID int, @Amount int, @AsOfDate datetime AS WITH Totals AS ( SELECT T.*, RunningTotal = Coalesce ( (SELECT Sum(S.Buyin - Coalesce(S.CreditPaid, 0)) FROM [Transaction] S WHERE T.CustomerID = S.CustomerID AND S.Type = 'Credit' AND S.Buyin &gt; Coalesce(T.CreditPaid, 0) AND ( T.Starttime &gt; S.Starttime OR ( T.Starttime = S.Starttime AND T.TransactionID &gt; S.TransactionID ) ) ), 0) FROM [Transaction] T WHERE CustomerID = @CustomerID AND T.Type = 'Credit' AND T.Buyin &gt; Coalesce(T.CreditPaid, 0) ) UPDATE T SET T.EndTime = P.EndTime, T.CreditPaid = Coalesce(T.CreditPaid, 0) + P.CreditPaid FROM Totals T CROSS APPLY ( SELECT TOP 1 V.* FROM (VALUES (T.Buyin - Coalesce(T.CreditPaid, 0), @AsOfDate), (@Amount - RunningTotal, NULL) ) V (CreditPaid, EndTime) ORDER BY V.CreditPaid, V.EndTime DESC ) P WHERE T.RunningTotal &lt;= @Amount AND @Amount &gt; 0; ; </code></pre> <p>VB Code:</p> <pre><code>Private Sub btnTransProcess_Click(sender As Object, e As EventArgs) Handles btnTransProcess.Click Dim iAmount As Integer Dim drv As DataRowView = CType(Me.cboCustomerName.SelectedItem, DataRowView) Dim SelCustId As Integer SelCustId = drv.Item("CustomerID") Try iAmount = CType(txtCreditPayment.Text, Integer) Catch ex As Exception MessageBox.Show("Enter a valid Credit Payment Amount!", "Invalid Amount", MessageBoxButtons.OK, MessageBoxIcon.Warning) End Try MsgBox(SelCustId) Me.TransactionTableAdapter.spPaymentApply(130, iAmount, Now) ' 'Dim command As New SqlCommand(queryString, connection) 'command.Parameters.AddWithValue("@CustomerID", 123) End Sub </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload