当我尝试使用 C# 将记录插入表中时,出现以下错误,
Message = "ORA-01036: illegal variable name/number\n"
Source = "System.Data.OracleClient"
StackTrace = " at System.Data.OracleClient.OracleConnection.CheckError(OciErrorHandle errorHandle, Int32 rc)\r\n at System.Data.OracleClient.OracleParameterBinding.Bind(OciStatementHandle statementHandle, NativeBuffer parameterBuffer, OracleConnection connection, Bo...
TargetSite = {Void CheckError(System.Data.OracleClient.OciErrorHandle, Int32)}
我的代码:
Int32 intLogID = 0;
strSQL = "INSERT INTO log_data(log_id, response_msg) "
+ "VALUES(?, ?)";
OracleCommand cmd = new OracleCommand(strSQL, conn);
cmd.CommandText = strSQL;
cmd.CommandType = CommandType.Text;
cmd.Parameters.Add("log_id", OracleType.Int32).Value = intLogID;
cmd.Parameters.Add("response_msg", OracleType.VarChar, 256).Value = strResMsg;
cmd.ExecuteNonQuery();
我的表结构:
LOG_ID NOT NULL NUMBER(18)
RESPONSE_MSG VARCHAR2(256)
我能够成功插入表格当我手动尝试使用时,
INSERT INTO log_data(log_id, response_msg)
values (1067365, 'test');
我什至尝试int intLogID = 0;
过cmd.Parameters.Add("log_id", OracleType.Number).Value = intLogID;
还Int32
带有数字绑定组合和int
绑定Int32
组合。
但仍然得到同样的错误。可能是什么问题呢?