jtran007
asked on
Overflowexception
Hi expert,
While excuting one of mysql query, I come across the
overflowexception.
Attached is my code
Could you help?
Thks,
JT
While excuting one of mysql query, I come across the
overflowexception.
Attached is my code
Could you help?
Thks,
JT
string sqlDialCodes = "select distinct dialcode from carrier_current_rate " + " where dialcode like '" + countryCodeId + "%'";
MySqlCommand cmdDialCodes = new MySqlCommand(sqlDialCodes, connection);
MySqlDataReader rdDialCodes = cmdDialCodes.ExecuteReader();
//int countryCodeId = 0;
while (rdDialCodes.Read())
{
lstDialCodeCountry.Items.Add(new ListItem(rdDialCodes.GetInt32(0).ToString()));
//lstDialCodeCountry.Items.Add(rdDialCodes.GetInt32(0).ToString());
}
rdDialCodes.Close();
connection.Close();
Are there any values of that column that would indeed be invalid, if you say run query directly in query browser?
Additionally, why retrieve as integer and then convert to string? Why not just pull as string here and probably avoid the issue then you will most likely see the offending string value in your list.
rdDialCodes.GetString(0);
Additionally, why retrieve as integer and then convert to string? Why not just pull as string here and probably avoid the issue then you will most likely see the offending string value in your list.
rdDialCodes.GetString(0);
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Glad you found the issue and thanks for posting to help future readers think of one possible cause of their own issue.
Regards,
Kevin
Regards,
Kevin
ASKER
System.OverflowException was unhandled by user code
Message="Value was either too large or too small for an Int32."
Source="mscorlib"
StackTrace:
at System.Convert.ToInt32(Int
at System.Int64.System.IConve
at MySql.Data.MySqlClient.MyS
at WebApplication1.carriercod
at System.Web.UI.WebControls.
at System.Web.UI.WebControls.
at System.Web.UI.WebControls.
at System.Web.UI.Page.RaiseCh
at System.Web.UI.Page.Process
InnerException: