Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

SQLHelper error System.InvalidCastException: Object must implement IConvertible.

6 views
Skip to first unread message

nana

unread,
Apr 1, 2003, 7:21:01 AM4/1/03
to
Hello

please help

i get this error when calling the ExecuteDataset method
in SQLHelper.cs, can anyone tell me what it could be? i
am lost here...

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 342:
Line 343: //fill the DataSet using
default values for DataTable names, etc.
Line 344: da.Fill(ds);
Line 345:
Line 346: // detach the
SqlParameters from the command object, so they can be
used again.

Source File:
c:\inetpub\wwwroot\buereu\components\sqlhelper.cs
Line: 344


my code that calls the SQLHelper.cs looks like this

public static SimpleReportCollection GetMTCDR(string
SystemID, string Addr)
{
SqlParameter [] arParms = new
SqlParameter[2];

arParms[0] = new SqlParameter
("@SystemID", SqlDbType.VarChar,25);
arParms[0].Value = SystemID;
arParms[1] = new SqlParameter
("@Addr", SqlDbType.VarChar,25);
arParms[1].Value = Addr;

DataSet dsData =
SqlHelper.ExecuteDataset(ConfigurationSettings.AppSettings
["ConnectionString1"], "GetAdminCDR", arParms);
SimpleReportCollection items =
new SimpleReportCollection();

foreach(DataRow row in
dsData.Tables[0].Rows)
{
SimpleReport item = new
SimpleReport();
item.sourceAddr = row
["sourceAddr"].ToString();
item.destinationAddr = row
["destinationAddr"].ToString();
item.payload = row
["payloadsection"].ToString();
if (row
["twistSubmitDateTime"] != DBNull.Value)
{

item.submitDatetime = row
["twistSubmitDateTime"].ToString();
}
else
{

item.submitDatetime = "NULL";

}

if (row["drDateTime"] !=
DBNull.Value)
{

item.deliveryDatetime = row["drDateTime"].ToString
();
}
else
{

item.deliveryDatetime = "NULL";
}
item.status = row
["status"].ToString();
items.Add(item);
}
return items;
}

Thanks :)

Cedric Bertolasio

unread,
Apr 19, 2003, 7:54:19 PM4/19/03
to
I have the same issue but with the VB.NET version. Have you been able to
find anything out yet?


"nana" <ringti...@webmail.co.za> wrote in message
news:01ff01c2f849$283ca7c0$3001...@phx.gbl...

Gerald Esch

unread,
Apr 28, 2003, 7:03:36 PM4/28/03
to
I am getting the same thing on both ExecuteDataset and
ExecuteReader. Has anyone found a solution?

>.
>

Jeff Schwandt

unread,
Jun 16, 2003, 3:02:56 PM6/16/03
to
I ran into this problem almost a year ago when I started
working with the DAAB. I found a problem in the overload
of ExecuteReader(SqlConnection, String, Object()). It
calls another overload of ExecuteReader but leaves out the
first parameters:

'wrong - leaves out the connection parameter:
Return ExecuteReader(CommandType.StoredProcedure, spName,
commandParameters)

'right:
Return ExecuteReader(connection,
CommandType.StoredProcedure, spName, commandParameters)

FYI, unit testing with NUnit helped me find this bug. I
let MS know about it, but I don't think they fixed it.

>.
>

Pranav Shah

unread,
Nov 25, 2003, 11:40:57 AM11/25/03
to
I have the right code in SqlHelper.cs but I still get the error. Any
thoughts??


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Ariel Gimenez

unread,
Jan 4, 2004, 8:04:38 AM1/4/04
to
Ok im having the same problem...
here is the code
 

SqlParameter[] arrparams = new SqlParameter[2];

arrparams[0] = new SqlParameter("@pwd",pwd);

arrparams[1] = new SqlParameter("@id",id);

object o = SqlHelper.ExecuteScalar(ConnectionString.cnn, "Pwd_Verificar", arrparams);

i get the IConvertible error of the subject, BTW if i change the code to this:

object[] arrparams = new object[2];

arrparams[0] = (string) pwd;

arrparams[1] = (int) id;

object o = SqlHelper.ExecuteScalar(ConnectionString.cnn, "Pwd_Verificar", arrparams);

But in the DAAB documentation says the correct way is the first... , any help will be appreciated

 

 
 
"Pranav Shah" <ryth...@yahoo.com> wrote in message news:u1$lnL3sD...@TK2MSFTNGP09.phx.gbl...
0 new messages