Error Data Access Block

L

larzeb

I received an error from the ExecuteNonQuery command and I don't have
a clue where to begin to diagnose it.

The calling parameters are connection, CommandType.StoredProcedure,
SPName, Parms().

The connection was open, the type of command was Stored Procedure, the
name of the procedure was correct and the parameters looked OK. But it
must be something in the parms.

The error message was a System.InvalidCastException: Object must
implement IConvertible.
 
C

Cowboy \(Gregory A. Beamer\)

The best bet is to F11 through the entire process until you get to the line
that actually caused the exception. Set a breakpoint on that line and
carefully examine everything variable. Most likely, none of the parameters
has a correct value and appears that it can easily be cast as one of the
database types, but it is not converting correctly. Using a database type
instead, like SqlDecimal instead of decimal (if SQL Server), will solve any
of these issues.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************************************************
Think outside the box!
*************************************************
 
K

Kevin Yu [MSFT]

Thanks for Gregory's quick response.

Hi larzeb,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that when you're going to use
ExecuteNonQuery with Data Access App Block, an InvalidCastException was
thrown. If there is any misunderstanding, please feel free to let me know.

I agree with Gregory that we can try to check every variable. I think there
might be something wrong with the parameters. You have to check the type of
them carefully. Since the source code of the App Block is available, we can
also trace in to the method to see which line goes wrong.

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 

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