0

我在 1 个数据库中有 2 个表

TABLE 1: LOGS
TABLE 2: MASTER LIST

LOGS
HOST | USER | NAME
==================
1    | A    | A1 
1    | A    | B1
1    | A    | C1
1    | A    | D1

MASTER LIST 
HOST | USER | NAME
===================
1    | A    | A1
1    | A    | B1
1    | A    | C1

在我的 C# 程序中,我有一个 gridview,我需要突出显示未包含在主列表中的行

LOGS
HOST | USER | NAME
==================
1    | A    | A1 
1    | A    | B1
1    | A    | C1
**1    | A    | D1**

这是我的 C# 代码:

           //Create the OracleCommand

            OracleCommand OCom = new OracleCommand("SERVERSTATUS.LOG_LIST", oc);

            OCom.CommandType = CommandType.StoredProcedure;

           OCom.Parameters.Add("out_RESULT", OracleType.Cursor).Direction = ParameterDirection.Output;

            OCom.Parameters[0].Value = sid;

            OracleDataAdapter _daGrid1 = new OracleDataAdapter(OCom);

            _daGrid1.Fill(_dsGrid);

            _daGrid1.Dispose();
            _daGrid1 = null;

            OCom.Dispose();
            OCom = null;

            if (frm_IT010_03 == null)
            {
                //button click show form with gridview
                frm_IT010_03 = new IT010_03(_dsGrid); 
                frm_IT010_03.ShowDialog();
            }

Class LogArray:这个类将数据从数据库存储到数组中。我怎样才能调用这个类?所以我可以将它与网格进行比较..

 public void LogArray(ArrayList al)
    {

        OracleConnection oc = new OracleConnection(ConOra);
        DataSet _dsGrid = new DataSet();

        try
        {
            oc.Open();
        }
        catch (OracleException ex)
        {
            MessageBox.Show(ex.ToString());
        }

        try
        {
            OracleCommand OCom = new OracleCommand("SERVERSTATUS.LOG_STATUS", oc);
            OCom.CommandType = CommandType.StoredProcedure;

            OCom.Parameters.Add("out_RESULT", OracleType.Cursor).Direction = ParameterDirection.Output;

            OracleDataReader DataReader = OCom.ExecuteReader();

            while (DataReader.Read())
            {
                al.Add(DataReader.GetString(0));
            }

        }
        catch
     {
    ...
     }  

我在 Oracle 中编译了一个包含 2 个过程的包

Package name: Server Status
Procedure name: **Log_list** = Calls for the Logs Table
Procedure name: **Log_status** = Calls for the values that are in the logs table but is not included in the master list table.

谢谢!!=))

4

1 回答 1

0

我不确定我是否理解你,但如果你只需要知道要突出显示哪些记录,那么你可以在 sql(或 plsql)中拥有它。

您的查询可能是这样的:

select l.HOST, l.USER, l.NAME, case when ml.HOST is null then 1 else 0 end is_to_highlight
from LOGS l left outer join MASTER_LIST ml on l.HOST = ml.HOST 
and l.USER= ml.USER 
and l.NAME = ml.NAME

这是一个 sqlfiddle 演示

于 2013-06-04T06:10:39.547 回答