Data Access Application Block Question - return param

  • Thread starter Thread starter moondaddy
  • Start date Start date
M

moondaddy

I dont know if this is the correct group to place this question, but it
seemed like the most likely. In the DAAB, I dont see any methods that
return a parameter. Is there an NonExecuteQuery method where I can use a
return parameter?

Thanks.
 
Does ExecuteScalar do what you need?

Private Function lookUpSingleItem(ByVal connectionString As String, ByVal
productID As Integer) As String
Try

Dim productName As String


' Call ExecuteScalar static method of SqlHelper class that returns an
Object. Then cast the return value to string.

' We pass in database connection string, command type, stored procedure
name and productID SqlParameter

productName = CType(SqlHelper.ExecuteScalar(connectionString,
CommandType.StoredProcedure, _

"getProductName", New
SqlParameter("@ProductID", productID)), String)


' return product name as a string

Return productName


Catch ex As Exception

' Log exception details

Throw ex

End Try

End Function
 
Yes, but a lot of my SPs are already setup to return a parameter and I
already have lots of code using those return parameters. I can edit the SPs
to return a scalar value, but I was just hoping there was something in the
DAAB that I could use to capture the return params.

--
(e-mail address removed)
Jim Hughes said:
Does ExecuteScalar do what you need?

Private Function lookUpSingleItem(ByVal connectionString As String, ByVal
productID As Integer) As String
Try

Dim productName As String


' Call ExecuteScalar static method of SqlHelper class that returns an
Object. Then cast the return value to string.

' We pass in database connection string, command type, stored procedure
name and productID SqlParameter

productName = CType(SqlHelper.ExecuteScalar(connectionString,
CommandType.StoredProcedure, _

"getProductName", New
SqlParameter("@ProductID", productID)), String)


' return product name as a string

Return productName


Catch ex As Exception

' Log exception details

Throw ex

End Try

End Function
 
Back
Top