| localSQL = "SELECT MAX(ITEM_ID) FROM SYS_ITEM"; |
| OracleCommand cmdOracle = new OracleCommand(localSQL, localConnection); |
| cmdOracle.CommandType = CommandType.Text; |
| OracleDataReader drOracle = cmdOracle.ExecuteReader(); |
| if (drOracle.Read()) |
| {addlocaidBox.Text = drOracle.GetOracleValue(0).ToString();} |
The code look like this.I'd welcome any suggestions or advice.

Jan MontanoRank #1,295 · 1.3K reputationPosted Feb 3, 2009, 4:44 PM EST
tommy32 reputationPosted Feb 3, 2009, 5:50 PM EST
Thanks for your help,but when i ran the code the exception error of
"Specified Cast not vaild" appeared.
Jan MontanoRank #1,295 · 1.3K reputationPosted Feb 3, 2009, 6:40 PM EST
try this instead
addlocaidBox.Text = (Convert.ToDouble(drOracle.GetOracleValue(0)) + 1).ToString();
tommy32 reputationPosted Feb 3, 2009, 7:47 PM EST
addlocaidBox.Text = (Convert.ToDouble(drOracle.GetOracleValue(0)) + 1).ToString();
It prompts...
System.InvalidCastException: Unable to cast object of type 'Oracle.DataAccess.Types.OracleDecimal' to type 'System.|Convertible'.
at System.Convert.ToDouble(Object value)
and even if i convert it to ToDecimal the same error msg appears but at System.Convert.ToDecimal(Object value)
Jan MontanoRank #1,295 · 1.3K reputationPosted Feb 3, 2009, 8:20 PM EST
Try this:
addlocaidBox.Text = (drOracle.GetOracleValue(0) + 1).ToString();
tommy32 reputationPosted Feb 3, 2009, 9:40 PM EST
addlocaidBox.Text = (drOracle.GetOracleValue(0) + 1).ToString();
The underlined section got a compilation error of
Operator '+' cannot be applied to operands of type 'object' and 'int'
I tried addlocaidBox.Text = (drOracle.GetOracleValue(0) )+1.ToString();
But resulted in the number with a 1 behind it...
Jan MontanoRank #1,295 · 1.3K reputationPosted Feb 3, 2009, 10:00 PM EST
I need to look at the documentation now.
looking at the documenation from this site:
we could use an OracleDecimal.Add function to add two OracleDecimal variables
addlocaidBox.Text = OracleDecimal.Add(drOracle.GetOracleValue(0),1).ToString();
tommy32 reputationPosted Feb 4, 2009, 12:29 AM EST
Well as they say 3 times a charm.
Thanks! it finally worked with
addlocaidBox.Text = OracleDecimal.Add(drOracle.GetOracleDecimal(0),1).ToString();