I executed the stored procedure,
AmountsOwed. I had to modify your code a little bit to make it work. However, I'm getting the following error message on the ASP.net page:
Compiler Error Message: BC30452: Operator '&' is not defined for types 'String' and 'System.Data.SqlClient.SqlDataReader'.
Source Error:
|
Line 232:
Line 233: 'Display Payment owed
Line 234: lblAmounts.Text = "Amount Owed $" & objcommand.ExecuteReader()
|
. I am very interested in using more complicated stored procedures.
Here's my code:
Sub AmountOwed()
Dim strConnect As String
Dim objConnect As SqlConnection
Dim objCommand As New SqlCommand
Dim strClientID As String
'Get connection string from Web.Config
strConnect = ConfigurationSettings.AppSettings("ConnectionString")
objConnect = New SqlConnection(strConnect)
'objConnect.Open()
'Get incoming Client ID
strClientID = request.params("qryID")
objCommand.Connection = objConnect
objCommand.CommandType = CommandType.StoredProcedure
objCommand.CommandText = "AmountsOwed"
objCommand.Parameters.Add("@ClientId", CInt(strClientId))
'objCommand = New SqlCommand( "SELECT SumOfPaymentOwed = CASE WHEN ISNULL(Sum(Amounts.PaymentOwed),0) = 0 THEN 0 ELSE CONVERT(DECIMAL(10,2),Sum(Amounts.PaymentOwed)) END FROM Amounts WHERE PaidDate is Null AND ClientID = '" & strClientID & "'" , objConnect )
'Display Payment owed
lblAmounts.Text = "Amount Owed $" & objcommand.ExecuteReader()
objConnect.Close()
End Sub