object must implement IConvertible 
Author Message
 object must implement IConvertible

I know others have had this problem but I can't find the answer.

I am using the SqlHelper class I downloaded from MSDN.
I am get an error on the cmd.ExecuteNonQuery()

The error is: object must implement the IConvertible

I am passing a single parameter array entry with a SqlDbType of Char -
length 10

SqlParameter [] arParms = new SqlParameter[1];

arParms[0].Value = "test";

The stored procedure is simple:

CREATE PROCEDURE bthsp_AddTesttable

AS
    insert into bth_testtable
        (
            Field1
        )
        values
        (

        )
    return 0
GO



Mon, 04 Oct 2004 05:30:25 GMT  
 object must implement IConvertible
I love it when I answer my own questions.....

Here is the answer in case anyone comes across this.

In this case I was calling one of the many overloads in
SqlHelper.ExecutNonQuery.   There are 9 different overloads for this method.

I thought I was using the one who's parameters included a connectionstring -
a commandtext (spname) and a sqlparamater array.

In fact, that method takes a object array (just values) - not a sqlparameter
array.

The overload that takes the sqlparameters array requires a connection object
(not a string) - a commandtype, a commandtext (spname) and
a sqlparameter array.

If is use this overloaded method then it works fine.

Problem solved.


Quote:
> I know others have had this problem but I can't find the answer.

> I am using the SqlHelper class I downloaded from MSDN.
> I am get an error on the cmd.ExecuteNonQuery()

> The error is: object must implement the IConvertible

> I am passing a single parameter array entry with a SqlDbType of Char -
> length 10

> SqlParameter [] arParms = new SqlParameter[1];

> arParms[0].Value = "test";

> The stored procedure is simple:

> CREATE PROCEDURE bthsp_AddTesttable

> AS
>     insert into bth_testtable
>         (
>             Field1
>         )
>         values
>         (

>         )
>     return 0
> GO



Mon, 04 Oct 2004 11:58:37 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. System.InvalidCastException: Object must implement IConvertible.

2. Update Object must implement IConvertible??

3. IConvertible Casting

4. Do I really need to use IConvertible?

5. Help w/ IConvertible

6. Implementing an COM object

7. COM interop and objects that don't implement IUnknown

8. Implementing object creation in C++

9. Implement some Object-Oriented features with C

10. How to implement change notification from my COM object (ATL 7.0)

11. COM Objects that implement TCP/IP services

12. COM objects that implement TCP/IP services

 

 
Powered by phpBB® Forum Software