错误更新查询的Visual Studio 2010 - 甲骨文11g快捷版 [英] Error in Update query-Visual Studio 2010- Oracle 11g Express edition
问题描述
我想在Visual Studio 2010旗舰版与Windows窗体作为前端执行更新操作和Oracle 11g Express作为后端。
我使用C#编写这一点。
I am trying to perform update action in Visual Studio 2010 Ultimate with Windows form as the front end and Oracle 11g express as the back end. I am using C# to code this.
private void update_student(string STUDENT_ID, string STUDENT_NAME, string STUDENT_ADDRESS)
{
con.Open();
String sql = "UPDATE STUDENT SET STUDENT_NAME = :STUDENT_NAME, STUDENT_ADDRESS= :STUDENT_ADDRESS WHERE STUDENT_ID= :STUDENT_ID";
OracleCommand query = new OracleCommand(sql, con);
OracleParameter[] updatestud = new OracleParameter[3];
updatestud[0] = query.Parameters.Add("STUDENT_ID", OracleDbType.Varchar2, STUDENT_ID, ParameterDirection.Input);
updatestud[1] = query.Parameters.Add("STUDENT_NAME", OracleDbType.Varchar2, STUDENT_NAME, ParameterDirection.Input);
updatestud[2] = query.Parameters.Add("STUDENT_ADDRESS", OracleDbType.Varchar2, STUDENT_ADDRESS, ParameterDirection.Input);
query.ExecuteNonQuery();
MessageBox.Show("Row Updated");
con.Close();
}
执行插入和检索操作之后,我现在尝试更新查询。
After performing insertion and retrieval actions I am now trying out Update query.
我不明白的参数,下面的代码,我在我的应用程序已经使用的价值流。
我得到了 query.ExecuteNonQuery()以下的错误;
行:
I couldn't understand the flow of parameters and values of the following code that I have used in my application.
I get the following error in the query.ExecuteNonQuery();
line:
ORA-01722:无效数字
ORA-01722: invalid number
任何帮助将非常感激。
推荐答案
字符串到数字的上尝试转换失败
< STRONG>因为字符串不是有效的数字文本。只有
数字字段或包含数字的数据字符字段可用于
的算术函数或表达式。只有数字字段可能
增加或从日期减去。
The attempted conversion of a character string to a number failed because the character string was not a valid numeric literal. Only numeric fields or character fields containing numeric data may be used in arithmetic functions or expressions. Only numeric fields may be added to or subtracted from dates.
这错误可能可能让你尝试定义你的 student_id数据
为 OracleDbType.Varchar2
。
This error may cause probably you try to define your STUDENT_ID
as a OracleDbType.Varchar2
.
我不知过了多久你的 student_id数据
但你可以使用 OracleDbType.Int32
代替。
I'm not sure how long your STUDENT_ID
but you can use OracleDbType.Int32
instead of.
等;
updatestud[0] = query.Parameters.Add("STUDENT_ID", OracleDbType.Int32 , STUDENT_ID, ParameterDirection.Input);
检查出的 OracleType
枚举的更多细节。
Check out OracleType
enumeration for more details.
指定的字段或财产使用在
的OracleParameter的数据类型。
Specifies the data type of a field or property for use in an OracleParameter.
这篇关于错误更新查询的Visual Studio 2010 - 甲骨文11g快捷版的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!