How to fix the 'Object must implement IConvertible' error when using the Enterprise Library

  • Thread starter Thread starter Jason Kolb
  • Start date Start date
J

Jason Kolb

So I can find this when I google it again sometime because I've
forgotten the fix :)

<Description("Wrapper class for Data Access block
ExecuteNonQuery")> _
Public Shared Function ExecuteNonQuery(ByVal ds As DataSource,
ByVal cmdText As String, ByVal params As Array) As Integer
Dim parms As New ArrayList(params)
Dim db As Database

db = GetDatabase(ds) ' App-specific, normally just get a
database object

Dim pValues(parms.Count - 1) As Object
For i As Integer = 0 To parms.Count - 1
pValues(i) = CType(parms(i), SqlParameter).Value
Next

' NOTE: Had to modify this function in the Application
Block to accept an array of SqlParameters
Dim ret As Integer = db.ExecuteNonQuery(cmdText, pValues)

Return ret
End Function
 
The DAAB uses the order of the parameter values to load up the
parameters themselves. It needs an array of values, not an array of
SqlParameters like the old DAB. Since most of my code was written to
pass an array of SqlParameters I had to add this wrapper function to
make my code play nice with the Enterprise Library.
 
Back
Top