System.InvalidCastException: Object must implement IConvertible. 
Author Message
 System.InvalidCastException: Object must implement IConvertible.

Thank you all for helping me.  I just about have my web
page done, but now I am getting the following error:

System.InvalidCastException: Object must implement
IConvertible.

This happens after the user hits the ADD button.  Here is
the code for that:

private void btnAddPN_Click(Object sender, EventArgs E)
{
SqlConnection MyConnection2 = new SqlConnection
("server=brake;database=ecn;trusted_connection=yes;");
        SqlDataAdapter MyDataAdapter2 = new SqlDataAdapter
("insert_pn", MyConnection2);
        MyDataAdapter2.SelectCommand.CommandType =
CommandType.StoredProcedure;
        MyDataAdapter2.SelectCommand.Parameters.Add(new

        MyDataAdapter2.SelectCommand.Parameters

        MyDataAdapter2.SelectCommand.Parameters.Add(new

        MyDataAdapter2.SelectCommand.Parameters

        MyDataAdapter2.SelectCommand.Parameters.Add(new

        MyDataAdapter2.SelectCommand.Parameters

        MyDataAdapter2.SelectCommand.Parameters.Add(new

        MyDataAdapter2.SelectCommand.Parameters

        MyDataAdapter2.SelectCommand.Parameters.Add(new

        MyDataAdapter2.SelectCommand.Parameters

        DataSet DS2 = new DataSet();
        MyDataAdapter2.Fill(DS2, "NewECN");
        GrdEcn.DataSource = DS2.Tables
["NewECN"].DefaultView;
        GrdEcn.DataBind();
        MyDataAdapter2.Dispose();
        MyConnection2.Close();

Quote:
}

Here is the stack trace:

[InvalidCastException: Object must implement IConvertible.]
   System.Data.SqlClient.SqlCommand.ExecuteReader
(CommandBehavior cmdBehavior, RunBehavior runBehavior,
Boolean returnStream) +643

System.Data.SqlClient.SqlCommand.System.Data.IDbCommand.Exe
cuteReader(CommandBehavior behavior) +9
   System.Data.Common.DbDataAdapter.Fill(Object data,
Int32 startRecord, Int32 maxRecords, String srcTable,
IDbCommand command, CommandBehavior behavior) +121
   System.Data.Common.DbDataAdapter.Fill(DataSet dataSet,
Int32 startRecord, Int32 maxRecords, String srcTable,
IDbCommand command, CommandBehavior behavior) +77
   System.Data.Common.DbDataAdapter.Fill(DataSet dataSet,
String srcTable) +36
   ASP.AddECN_aspx.btnAddPN_Click(Object sender, EventArgs
E) in
e:\Inetpub\wwwroot\dept_engineering\ECN\Insert\AddECN.aspx:
108
   System.Web.UI.WebControls.Button.OnClick(EventArgs e)
+108

System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEve
ntHandler.RaisePostBackEvent(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() +1263

Thanks.



Sun, 12 Dec 2004 23:37:01 GMT  
 System.InvalidCastException: Object must implement IConvertible.
BTW, the line number with the error is:

MyDataAdapter2.Fill(DS2, "NewECN");

Quote:
>-----Original Message-----
>Thank you all for helping me.  I just about have my web
>page done, but now I am getting the following error:

>System.InvalidCastException: Object must implement
>IConvertible.

>This happens after the user hits the ADD button.  Here is
>the code for that:

>private void btnAddPN_Click(Object sender, EventArgs E)
>{
>SqlConnection MyConnection2 = new SqlConnection
>("server=brake;database=ecn;trusted_connection=yes;");
>    SqlDataAdapter MyDataAdapter2 = new SqlDataAdapter
>("insert_pn", MyConnection2);
>    MyDataAdapter2.SelectCommand.CommandType =
>CommandType.StoredProcedure;
>    MyDataAdapter2.SelectCommand.Parameters.Add(new

>    MyDataAdapter2.SelectCommand.Parameters

>    MyDataAdapter2.SelectCommand.Parameters.Add(new

>    MyDataAdapter2.SelectCommand.Parameters

>    MyDataAdapter2.SelectCommand.Parameters.Add(new

>    MyDataAdapter2.SelectCommand.Parameters

>    MyDataAdapter2.SelectCommand.Parameters.Add(new

>    MyDataAdapter2.SelectCommand.Parameters

>    MyDataAdapter2.SelectCommand.Parameters.Add(new

>    MyDataAdapter2.SelectCommand.Parameters

>    DataSet DS2 = new DataSet();
>    MyDataAdapter2.Fill(DS2, "NewECN");
>    GrdEcn.DataSource = DS2.Tables
>["NewECN"].DefaultView;
>    GrdEcn.DataBind();
>    MyDataAdapter2.Dispose();
>    MyConnection2.Close();
>}

>Here is the stack trace:

>[InvalidCastException: Object must implement
IConvertible.]
>   System.Data.SqlClient.SqlCommand.ExecuteReader
>(CommandBehavior cmdBehavior, RunBehavior runBehavior,
>Boolean returnStream) +643

>System.Data.SqlClient.SqlCommand.System.Data.IDbCommand.Ex
e
>cuteReader(CommandBehavior behavior) +9
>   System.Data.Common.DbDataAdapter.Fill(Object data,
>Int32 startRecord, Int32 maxRecords, String srcTable,
>IDbCommand command, CommandBehavior behavior) +121
>   System.Data.Common.DbDataAdapter.Fill(DataSet dataSet,
>Int32 startRecord, Int32 maxRecords, String srcTable,
>IDbCommand command, CommandBehavior behavior) +77
>   System.Data.Common.DbDataAdapter.Fill(DataSet dataSet,
>String srcTable) +36
>   ASP.AddECN_aspx.btnAddPN_Click(Object sender,
EventArgs
>E) in
>e:\Inetpub\wwwroot\dept_engineering\ECN\Insert\AddECN.aspx
:
>108
>   System.Web.UI.WebControls.Button.OnClick(EventArgs e)
>+108

>System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEv
e
>ntHandler.RaisePostBackEvent(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() +1263

>Thanks.

>.



Sun, 12 Dec 2004 23:43:15 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. object must implement IConvertible

2. Update Object must implement IConvertible??

3. System.InvalidCastException

4. System.InvalidCastException thrown when using a WebService

5. System.InvalidCastException

6. foreach loop and System.InvalidCastException

7. System.InvalidCastException

8. InvalidCastException and COM objects

9. System::Object* to System::Array*

10. object vs System.Object

11. IConvertible Casting

12. Do I really need to use IConvertible?

 

 
Powered by phpBB® Forum Software