开发者

Count value within if statement

sorgu.CommandText = "select count(*) from mert";

I want to use within if statement to count value in that query.And,I want to access to that value.How can I do that?

Code:

OracleConnection conn = 开发者_如何学Cnew 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();

Cheers,


I have never used an Oracle database before, but per MSDN this is how you need to interact with your data:

  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());

So, for each column, you have to setup an OracleString, OracleNumber, OracleDateTime, OracleBinary, etc. The corresponding functions (e.g. GetOracleString(col)) is how you actually retrieve the data.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜