我得到這個錯誤「ORA-01722:非法/無效號碼」甲骨文插入查詢
decimal first2var = Convert.ToDecimal(var1);
decimal id_refeicao;
//...
// save values in var insted of lables
decimal id_usuario = (decimal)dr.GetInt32(0);
//...
var idUsuarioParameter = new OracleParameter
{
ParameterName = "id_usuario",
OracleDbType = OracleDbType.Decimal,
Direction = ParameterDirection.Input,
Value = id_usuario
};
var idRefeicaoParameter = new OracleParameter
{
ParameterName = "id_refeicao",
OracleDbType = OracleDbType.Decimal,
Direction = ParameterDirection.Input,
Value = id_refeicao
};
var var1Parameter = new OracleParameter
{
ParameterName = "first2var",
OracleDbType = OracleDbType.Decimal, //-- populate with correct oracle type
Direction = ParameterDirection.Input,
Value = first2var
};
OracleConnection connection = new OracleConnection(oradb);
connection.Open();
cmd.Connection = connection;
cmd.CommandText = "INSERT INTO SER_REFEICAO_USUARIO (USUARIO, REFEICAO, DATA_HORA, ORIGEM) VALUES(:id_usuario, :id_refeicao, SYSDATE , :first2var)";
cmd.Parameters.Add(idUsuarioParameter);
cmd.Parameters.Add(idRefeicaoParameter);
cmd.Parameters.Add(var1Parameter);
cmd.CommandType = CommandType.Text;
cmd.ExecuteNonQuery();
connection.Close();
誰能幫我什麼,我做錯了,如果我硬代碼我在我的插入查詢值,它工作正常,但如果我通過上面的參數,所以我得到了錯誤。
你爲什麼在你的命令tex裏有'var2',但是添加'var1'作爲參數?另外,是數字或字符串? –
@DanielKelley ID是數字,但我定義了數據類型字符串,像這樣「字符串id_usuario」 – user2956373
表SERCREFEICAO_USUARIO'的定義怎麼樣,你能告訴我們每個列是什麼類型? –