| 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.
tommyPosted Feb 4, 2009, 5:29 AM
Well as they say 3 times a charm.
Thanks! it finally worked with
addlocaidBox.Text = OracleDecimal.Add(drOracle.GetOracleDecimal(0),1).ToString();
Jan MontanoPosted Feb 4, 2009, 3:00 AM
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();
tommyPosted Feb 4, 2009, 2:40 AM
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 MontanoPosted Feb 4, 2009, 1:20 AM
Try this:
addlocaidBox.Text = (drOracle.GetOracleValue(0) + 1).ToString();
tommyPosted Feb 4, 2009, 12:47 AM
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 MontanoPosted Feb 3, 2009, 11:40 PM
try this instead
addlocaidBox.Text = (Convert.ToDouble(drOracle.GetOracleValue(0)) + 1).ToString();
tommyPosted Feb 3, 2009, 10:50 PM
Thanks for your help,but when i ran the code the exception error of
"Specified Cast not vaild" appeared.
Jan MontanoPosted Feb 3, 2009, 9:44 PM