sorgu.CommandText = "select count(*) from mert";
我想在 if 语句中使用来计算该查询中的值。我想获得这个价值。我怎样才能做到这一点?
代码:
OracleConnection conn = new OracleConnection(@"DATA SOURCE=;USER ID=orcl2; Password=123");
conn.Open();
OracleCommand sorgu = new OracleCommand();
sorgu.CommandText = "select * from mert";
sorgu.Connection = conn;
OracleDataReader oku = sorgu.ExecuteReader();
while (oku.Read())
{
if (oku[0].ToString() == textBox1.Text && oku[1].ToString() == textBox2.Text)
{
Form2 f = new Form2();
f.ShowDialog();
}
}
oku.Close();
我以前从未使用过 Oracle 数据库,但根据 MSDN,这就是您与数据交互的方式:
command.CommandText = "SELECT * FROM OracleTypesTable";
OracleDataReader reader = command.ExecuteReader();
reader.Read();
//Using the Oracle specific getters for each type is faster than
//using GetOracleValue.
//First column, MyVarchar2, is a VARCHAR2 data type in Oracle Server
//and maps to OracleString.
OracleString oraclestring1 = reader.GetOracleString(0);
Console.WriteLine("OracleString " + oraclestring1.ToString());
//Second column, MyNumber, is a NUMBER data type in Oracle Server
//and maps to OracleNumber.
OracleNumber oraclenumber1 = reader.GetOracleNumber(1);
Console.WriteLine("OracleNumber " + oraclenumber1.ToString());
因此,对于每一列,您必须设置一个
OracleString
、OracleNumber
、OracleDateTime
、OracleBinary
等。相应的函数(例如 GetOracleString(col)
)就是您实际检索数据的方式。