Posted on 2009-07-16
Last Modified: 2012-05-07
Hi expert,

While excuting one of mysql query, I come across the

Attached is my code
Could you help?
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()));






Open in new window

Question by:jtran007
  • 2
  • 2

Author Comment

ID: 24873042
Continued ...

System.OverflowException was unhandled by user code
  Message="Value was either too large or too small for an Int32."
       at System.Convert.ToInt32(Int64 value)
       at System.Int64.System.IConvertible.ToInt32(IFormatProvider provider)
       at MySql.Data.MySqlClient.MySqlDataReader.GetInt32(Int32 i)
       at WebApplication1.carriercode.lstCountry_SelectedIndexChanged(Object sender, EventArgs e) in C:\Develop\Date\June16\MyReport\carriercode.aspx.cs:line 378
       at System.Web.UI.WebControls.ListControl.OnSelectedIndexChanged(EventArgs e)
       at System.Web.UI.WebControls.ListBox.RaisePostDataChangedEvent()
       at System.Web.UI.WebControls.ListBox.System.Web.UI.IPostBackDataHandler.RaisePostDataChangedEvent()
       at System.Web.UI.Page.RaiseChangedEvents()
       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
LVL 59

Expert Comment

by:Kevin Cross
ID: 24873152
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.


Accepted Solution

jtran007 earned 0 total points
ID: 24889032
Hi expert,

It is working now: i changed  ..Int32(0)  to Int64(0).

LVL 59

Expert Comment

by:Kevin Cross
ID: 24895347
Glad you found the issue and thanks for posting to help future readers think of one possible cause of their own issue.


Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Class object 2 28
VB.Net How to Exit Sub - Exit Form??? 5 51
Amazon Redshift 2 28
free scanner TWAIN can be operated with a Web application 9 43
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now