Help w/ IConvertible 
Author Message
 Help w/ IConvertible

Any help with this would be greatly appreciated:

I'm uploading an image to a database etc, as far as I can see my code should
be "working code" though every time I try to execute it I get the following
error msg:

Object must implement IConvertible.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
----------------------------------------------------------------------------
---------------
Exception Details: System.InvalidCastException: Object must implement
IConvertible.

Source Error:


Line 369:
Line 370:     myCommand.ExecuteReader();//.ExecuteNonQuery();
Line 371:     myCommand.Dispose();
Line 372:     myConnection.Close();

Source File: c:\inetpub\wwwroot\wisebospro\product_add_new.aspx.cs    Line:
370
----------------------------------------------------------------------------
---------------

Source code:

        myConnection = new
SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
        myConnection.Open();
        myCommand = new SqlCommand("spx_Product_Image_Insert ",
myConnection);
        uplImage = frmImage.PostedFile;
        if (uplImage.ContentLength != 0)
        {
            Byte[] uplImageBArray = new System.Byte[uplImage.ContentLength];
//FileByteArrayA = uplImageBArray
            Stream myStream = uplImage.InputStream; // StreamObjectA =
myStream
            myStream.Read(uplImageBArray, 0, uplImage.ContentLength);


SqlDbType.Image));


SqlDbType.NVarChar));

uplImage.ContentType;


SqlDbType.Int));

uplImage.ContentLength;


SqlDbType.Int));


SqlDbType.NVarChar));


SqlDbType.Bit));

            myCommand.ExecuteNonQuery();
            myCommand.Dispose();
            myConnection.Close();
            myConnection.Dispose();
        }

Best regards
 Ronny Engen



Fri, 16 Jul 2004 20:54:41 GMT  
 Help w/ IConvertible
Ronny,

    Your code looks correct.  Can you give a full stack trace?

--
                              - Nicholas Paldino [.NET MVP]


Quote:
> Any help with this would be greatly appreciated:

> I'm uploading an image to a database etc, as far as I can see my code
should
> be "working code" though every time I try to execute it I get the
following
> error msg:

> Object must implement IConvertible.
> Description: An unhandled exception occurred during the execution of the
> current web request. Please review the stack trace for more information
> about the error and where it originated in the code.
> --------------------------------------------------------------------------
--
> ---------------
> Exception Details: System.InvalidCastException: Object must implement
> IConvertible.

> Source Error:


> Line 369:
> Line 370:     myCommand.ExecuteReader();//.ExecuteNonQuery();
> Line 371:     myCommand.Dispose();
> Line 372:     myConnection.Close();

> Source File: c:\inetpub\wwwroot\wisebospro\product_add_new.aspx.cs
Line:
> 370
> --------------------------------------------------------------------------
--
> ---------------

> Source code:

>         myConnection = new
> SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
>         myConnection.Open();
>         myCommand = new SqlCommand("spx_Product_Image_Insert ",
> myConnection);
>         uplImage = frmImage.PostedFile;
>         if (uplImage.ContentLength != 0)
>         {
>             Byte[] uplImageBArray = new

System.Byte[uplImage.ContentLength];
Quote:
> //FileByteArrayA = uplImageBArray
>             Stream myStream = uplImage.InputStream; // StreamObjectA =
> myStream
>             myStream.Read(uplImageBArray, 0, uplImage.ContentLength);


> SqlDbType.Image));


> SqlDbType.NVarChar));

> uplImage.ContentType;

>             myCommand.Parameters.Add(new


- Show quoted text -

Quote:
> SqlDbType.Int));

> uplImage.ContentLength;


> SqlDbType.Int));


> SqlDbType.NVarChar));


> SqlDbType.Bit));

>             myCommand.ExecuteNonQuery();
>             myCommand.Dispose();
>             myConnection.Close();
>             myConnection.Dispose();
>         }

> Best regards
>  Ronny Engen



Fri, 16 Jul 2004 21:16:52 GMT  
 Help w/ IConvertible
First of all - Thank you for taking your time to look into my bugs!! Here's
the complete output (sorry for not providing it previously).

Server Error in '/WiseBosPro' Application.

Object must implement IConvertible.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.InvalidCastException: Object must implement
IConvertible.

Source Error:

        An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of the
exception can         be identifed using the exception stack trace below.

    Stack Trace:

        [InvalidCastException: Object must implement IConvertible.]
           System.Data.SqlClient.TdsParser.TdsExecuteRPC(_SqlRPC rec, Int32
timeout, Boolean inSchema) +1437
           System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream) +273
           System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +188
           WiseBosPro.product_add_new.btnAddProduct_Click(Object sender,
EventArgs e) +2615
           System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108

System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePo
stBackEvent(String eventArgument) +57
           System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +18
           System.Web.UI.Page.RaisePostBackEvent(NameValueCollection
postData) +33
           System.Web.UI.Page.ProcessRequestMain() +660

Version Information: Runtime Build:1.0.2914.16; ASP.NET Build:1.0.2914.16



Quote:
> Ronny,

>     Your code looks correct.  Can you give a full stack trace?

> --
>                               - Nicholas Paldino [.NET MVP]



> > Any help with this would be greatly appreciated:

> > I'm uploading an image to a database etc, as far as I can see my code
> should
> > be "working code" though every time I try to execute it I get the
> following
> > error msg:

> > Object must implement IConvertible.
> > Description: An unhandled exception occurred during the execution of the
> > current web request. Please review the stack trace for more information
> > about the error and where it originated in the code.

> --------------------------------------------------------------------------
> --
> > ---------------
> > Exception Details: System.InvalidCastException: Object must implement
> > IConvertible.

> > Source Error:


> > Line 369:
> > Line 370:     myCommand.ExecuteReader();//.ExecuteNonQuery();
> > Line 371:     myCommand.Dispose();
> > Line 372:     myConnection.Close();

> > Source File: c:\inetpub\wwwroot\wisebospro\product_add_new.aspx.cs
> Line:
> > 370

> --------------------------------------------------------------------------
> --
> > ---------------

> > Source code:

> >         myConnection = new
> > SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
> >         myConnection.Open();
> >         myCommand = new SqlCommand("spx_Product_Image_Insert ",
> > myConnection);
> >         uplImage = frmImage.PostedFile;
> >         if (uplImage.ContentLength != 0)
> >         {
> >             Byte[] uplImageBArray = new
> System.Byte[uplImage.ContentLength];
> > //FileByteArrayA = uplImageBArray
> >             Stream myStream = uplImage.InputStream; // StreamObjectA =
> > myStream
> >             myStream.Read(uplImageBArray, 0, uplImage.ContentLength);


> > SqlDbType.Image));

> >             myCommand.Parameters.Add(new


- Show quoted text -

Quote:
> > SqlDbType.NVarChar));

> > uplImage.ContentType;

> >             myCommand.Parameters.Add(new

> > SqlDbType.Int));

> > uplImage.ContentLength;


> > SqlDbType.Int));


> > SqlDbType.NVarChar));


> > SqlDbType.Bit));

> >             myCommand.ExecuteNonQuery();
> >             myCommand.Dispose();
> >             myConnection.Close();
> >             myConnection.Dispose();
> >         }

> > Best regards
> >  Ronny Engen



Fri, 16 Jul 2004 21:45:15 GMT  
 Help w/ IConvertible
I put the code inside a try/catch block - produced the following output:

System.InvalidCastException: Object must implement IConvertible. at
System.Data.SqlClient.TdsParser.TdsExecuteRPC(_SqlRPC rec, Int32 timeout,
Boolean inSchema) at
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior,
RunBehavior runBehavior, Boolean returnStream) at
System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at
WiseBosPro.product_add_new.btnAddProduct_Click(Object sender, EventArgs e)

Also, I am using a stored procedure on an  SQL Server 2000

CREATE PROCEDURE spx_Product_Image_Insert






AS
 INSERT INTO  tblProdImage
    (
    imgOrig,
    strOrigContType,
    intOrigContLength ,
    intProdID,
    strDesc,
    bitIsDefault
    )
 VALUES       (






    )
GO

Best Regards
   -Ronny Engen



Quote:
> Ronny,

>     Your code looks correct.  Can you give a full stack trace?

> --
>                               - Nicholas Paldino [.NET MVP]



> > Any help with this would be greatly appreciated:

> > I'm uploading an image to a database etc, as far as I can see my code
> should
> > be "working code" though every time I try to execute it I get the
> following
> > error msg:

> > Object must implement IConvertible.
> > Description: An unhandled exception occurred during the execution of the
> > current web request. Please review the stack trace for more information
> > about the error and where it originated in the code.

> --------------------------------------------------------------------------
> --
> > ---------------
> > Exception Details: System.InvalidCastException: Object must implement
> > IConvertible.

> > Source Error:


> > Line 369:
> > Line 370:     myCommand.ExecuteReader();//.ExecuteNonQuery();
> > Line 371:     myCommand.Dispose();
> > Line 372:     myConnection.Close();

> > Source File: c:\inetpub\wwwroot\wisebospro\product_add_new.aspx.cs
> Line:
> > 370

> --------------------------------------------------------------------------
> --
> > ---------------

> > Source code:

> >         myConnection = new
> > SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
> >         myConnection.Open();
> >         myCommand = new SqlCommand("spx_Product_Image_Insert ",
> > myConnection);
> >         uplImage = frmImage.PostedFile;
> >         if (uplImage.ContentLength != 0)
> >         {
> >             Byte[] uplImageBArray = new
> System.Byte[uplImage.ContentLength];
> > //FileByteArrayA = uplImageBArray
> >             Stream myStream = uplImage.InputStream; // StreamObjectA =
> > myStream
> >             myStream.Read(uplImageBArray, 0, uplImage.ContentLength);


> > SqlDbType.Image));

> >             myCommand.Parameters.Add(new


- Show quoted text -

Quote:
> > SqlDbType.NVarChar));

> > uplImage.ContentType;

> >             myCommand.Parameters.Add(new

> > SqlDbType.Int));

> > uplImage.ContentLength;


> > SqlDbType.Int));


> > SqlDbType.NVarChar));


> > SqlDbType.Bit));

> >             myCommand.ExecuteNonQuery();
> >             myCommand.Dispose();
> >             myConnection.Close();
> >             myConnection.Dispose();
> >         }

> > Best regards
> >  Ronny Engen



Fri, 16 Jul 2004 21:51:42 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. object must implement IConvertible

2. IConvertible Casting

3. Do I really need to use IConvertible?

4. System.InvalidCastException: Object must implement IConvertible.

5. Update Object must implement IConvertible??

6. HELP HELP HELP HELP HELP HELP!!!

7. HELP HELP HELP HELP HELP

8. HELP ++++++++++++++ HELP +++++++++++ HELP ++++++++++++++ HELP

9. OSP (Operating System Project) HELP HELP HELP HELP (files module)

10. HELP help HELP help

11. help VIRUS help help VIRUS help !

12. Please help!!!!Please help!!!!Please help!!!!Please help!!!!Please help!!!!Please help!!!!Please help!!!!

 

 
Powered by phpBB® Forum Software