473,383 Members | 1,789 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Int32 error

Ron,
What are you trying to do? Read from a database? This
error indicates that you are trying to read an int, but
the value is outside the range of an integer: -
2,147,483,648 through 2,147,483,647.

Tu-Thach
-----Original Message-----
Hi,
I am trying to find the meaing to the following error.
"Value was either too large or too small for an Int32."

Can someone give me some more information on this error?

Thanks Ron
.

Nov 15 '05 #1
2 8587
ron
It is happening in the the following methode i have.
The only thing i can think of is that it is happening
during one of the Parse routine's.
How can i define the trap to be better?
It dose not happen all the time just once in a while.

Thanks Ron

protected void GetJudgements()
{
int j = 0;
try
{
// Check test position's 1-5 judgement.
for(int i=4; i<84; i+=20)
{
judgements[j] = int.Parse(dmArray[i]);
j++;
}

// Check on-line status of test positions 6 and 7
// preform judgement logic accordingly.
if((TestOnline[5]) & (TestOnline[6]))
{
// Check test position 6 judgement.
judgements[5] = (0x0 != int.Parse(dmArray[113],
NumberStyles.HexNumber))? 1 : 0;
// Look at tracking and test flags for no-test condition.
judgements[5] = (dmArray[121].Substring(5,1) == "1" &
dmArray[122].Substring(5,1) == "0")? 2 : 0;

// Check test position 7 judgement
// Look at tracking and test flags for no-test condition.
if(dmArray[121].Substring(6,1) == "1" & dmArray
[122].Substring(6,1) == "0")
{
judgements[6] = 2;
}
else
{
judgements[6] = int.Parse(dmArray[104]);
}
}
else if((TestOnline[5] == true) & (TestOnline[6] ==
false))
{
judgements[5] = int.Parse(dmArray[104]);
}
else if((TestOnline[5] == false) & (TestOnline[6] ==
true))
{
judgements[6] = int.Parse(dmArray[104]);
}
}
catch(Exception e)
{
string errorMessage = "";

errorMessage = "Message: " + e.Message + "\n";

EventLog log = new EventLog();
log.Source = "DataCollectionServer";
log.WriteEntry(errorMessage);
}
}

-----Original Message-----
Ron,
What are you trying to do? Read from a database? This
error indicates that you are trying to read an int, but
the value is outside the range of an integer: -
2,147,483,648 through 2,147,483,647.

Tu-Thach
-----Original Message-----
Hi,
I am trying to find the meaing to the following error.
"Value was either too large or too small for an Int32."

Can someone give me some more information on this error?

Thanks Ron
.

.

Nov 15 '05 #2
ron
Tu-Thach,
You are correct i found the value in dmArray[113]
was "1000000000000110" which is equal to 32774.
So i decided to change that line to the following.

judgements[5] = (0 != Convert.ToInt32(dmArray[113], 2))?
1 : 0;

The value in dmArray[113] has the possability to hold the
following "1111111111111111" to "0000000000000000".

This should solve my problem i am only checking that
value to see if it is not equal to zero.

Thanks Ron
-----Original Message-----
Ron,
I think the data in dmArray that you are trying to parse
might be larger than the range of integer value.

Tu-Thach
-----Original Message-----
It is happening in the the following methode i have.
The only thing i can think of is that it is happening
during one of the Parse routine's.
How can i define the trap to be better?
It dose not happen all the time just once in a while.

Thanks Ron

protected void GetJudgements()
{
int j = 0;
try
{
// Check test position's 1-5 judgement.
for(int i=4; i<84; i+=20)
{
judgements[j] = int.Parse(dmArray[i]);
j++;
}

// Check on-line status of test positions 6 and 7
// preform judgement logic accordingly.
if((TestOnline[5]) & (TestOnline[6]))
{
// Check test position 6 judgement.
judgements[5] = (0x0 != int.Parse(dmArray[113],
NumberStyles.HexNumber))? 1 : 0;
// Look at tracking and test flags for no-test condition.judgements[5] = (dmArray[121].Substring(5,1) == "1" &
dmArray[122].Substring(5,1) == "0")? 2 : 0;

// Check test position 7 judgement
// Look at tracking and test flags for no-test condition.if(dmArray[121].Substring(6,1) == "1" & dmArray
[122].Substring(6,1) == "0")
{
judgements[6] = 2;
}
else
{
judgements[6] = int.Parse(dmArray[104]);
}
}
else if((TestOnline[5] == true) & (TestOnline[6] ==
false))
{
judgements[5] = int.Parse(dmArray[104]);
}
else if((TestOnline[5] == false) & (TestOnline[6] ==
true))
{
judgements[6] = int.Parse(dmArray[104]);
}
}
catch(Exception e)
{
string errorMessage = "";

errorMessage = "Message: " + e.Message + "\n";

EventLog log = new EventLog();
log.Source = "DataCollectionServer";
log.WriteEntry(errorMessage);
}
}

-----Original Message-----
Ron,
What are you trying to do? Read from a database? Thiserror indicates that you are trying to read an int, butthe value is outside the range of an integer: -
2,147,483,648 through 2,147,483,647.

Tu-Thach

-----Original Message-----
Hi,
I am trying to find the meaing to the following error.
"Value was either too large or too small for an Int32."
Can someone give me some more information on this error?
Thanks Ron
.

.

.

.

Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
by: jeff | last post by:
how do you convert form byte to Int32 while retaining the binary value of the byte array
3
by: Mike P | last post by:
Can anybody convert this from VB.NET to C#? If Int32.Parse(ID) = Int32.Parse(dt.Rows(iLoop)("ID")) then Return iLoop End If Thanks, lfc77
3
by: Christopher Crooker | last post by:
We had a function with the signature: Function(Object *, DateTime, DateTime, EnumType) and then changed the class some and there was a 4 parameter function with the signature: ...
1
by: Hifni Shahzard | last post by:
Hi, I got a stored procedure, where it returns a value. But if I execute it. It gives an error as "Invalid cast from System.Int32 to System.Byte.". To make clear how do I execute this, below I'm...
2
by: Simon Harris | last post by:
I have created a web service, which when I call in my browser presents the text form etc. When I click the button, I get this error: System.ArgumentException: Cannot convert to System.Int32....
1
by: Robin Tucker | last post by:
I have a customer (our first "beta" case as it happens) who has Norwegian Windows XP. Our software is not translated to Norwegian (yet), we just have the basic, default, EN version. Anyway, when...
4
by: bob95226 | last post by:
Hi All, I wrote a VB.NET control in Visual Studio 2003 IDE, I am trying to re-compile it with command line compiler vbc.exe like this: vbc /t:library /out:my_control.dll my_control.vb However...
3
by: keithb | last post by:
What could be causing this? this code: String Com = ""; if (Com != (String)rw.ItemArray) fails at runtime with the error message: Unable to cast object of type 'System.Int32' to type...
2
by: rob | last post by:
Hi, I'm a bit confused by the mapping of the native types int and long to UInt32. I'm trying to bind a tracking reference to a native value type and it works for Int32 % -int but not for Int32 %...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.