1
我有以下的方法和兩個PARAMATERS都爲空的OracleCommand查詢空參數中凡 - ORA-01008:結合並非所有變量
布爾hasValue的=的HasValue(NULL,NULL);
internal bool HasValue(int? param1, int? param2)
{
int count = 0;
using (var conn = new OracleConnection(connectionString))
{
using (var command = conn.CreateCommand())
{
command.CommandText = "select count(id) from Table1 "
+ "where ((Column1 = :PARAM1 and :PARAM1 Is Not Null) Or (Column1 Is Null and :PARAM1 Is Null)) "
+ "AND ((Column2 = :PARAM2 and :PARAM2 Is Not Null) Or (Column2 Is Null and :PARAM2 Is Null))";
command.Parameters.Add("PARAM1", OracleDbType.Int16, 0, param1, ParameterDirection.Input);
command.Parameters.Add("PARAM2", OracleDbType.Int16, 0,param2, ParameterDirection.Input);
command.Connection.Open();
count = Convert.ToInt16(command.ExecuteScalar());
command.Connection.Close();
}
}
return count > 0;
}
的方法失敗,出現以下錯誤「ORA-01008:未綁定的所有變量」
如果我只用一個參數,那麼它的罰款,但是當我將其添加失敗,「ORA-01008第二:未綁定」
在此先感謝
感謝它的工作對我的INT列,但沒有日期和字符串列 – MicroMan 2013-03-08 13:17:08
@Jeepers所有變量 - 舉個例子:你如何傳遞參數值以及返回的錯誤。 – 2013-03-08 13:27:39
這是用戶錯誤,它適用於所有......謝謝 – MicroMan 2013-03-08 14:53:16