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

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
 
J

Jason Kolb

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top