代码之家  ›  专栏  ›  技术社区  ›  Gold

C#+Oracle 11g帮助

  •  0
  • Gold  · 技术社区  · 15 年前

    我有这个快速搜索代码。它在sqlCE中工作得非常好

    SqlCeCommand Cmd;
    Cmd.CommandType = CommandType.TableDirect;
    Cmd.CommandText = "MEN";
    Cmd.IndexName = "A";
    Cmd.SetRange(DbRangeOptions.Match, new object[] { R[15].ToString().Trim(), MyDate }, null);
    SqlCeDataReader read = Cmd.ExecuteReader();
    while (read.Read())
    {
      TmpBAR = read[0].ToString();
    }
    read.Dispose();
    if (TmpBAR == "")
    {
      //return false;
    }
    

    OracleCommand Cmd;
    Cmd.CommandType = CommandType.TableDirect;
    Cmd.CommandText = "MEN";
    Cmd.IndexName = "A";
    Cmd.SetRange(DbRangeOptions.Match, new object[] { R[15].ToString().Trim(), MyDate }, null);
    OracleDataReader read = Cmd.ExecuteReader();
    while (read.Read())
    {
      TmpBAR = read[0].ToString();
    }
    read.Dispose();
    if (TmpBAR == "")
    {
      //return false;
     }
    

    我得到一个错误:

    System.Data.OracleClient.OracleCommand' does not contain a definition for 'IndexName' and no extension method 'IndexName' accepting a first argument of type 'System.Data.OracleClient.OracleCommand' could be found (are you missing a using directive or an assembly reference?)
    

    这个错误是:

    System.Data.OracleClient.OracleCommand' does not contain a definition for 'SetRange' and no extension method 'SetRange' accepting a first argument of type 'System.Data.OracleClient.OracleCommand' could be found (are you missing a using directive or an assembly reference?)
    
    2 回复  |  直到 15 年前
        1
  •  2
  •   Chris Taylor    15 年前

    您需要使用CommandType.Text并创建适当的SQL语句来从表中进行选择。您当前使用的功能是特定于SQLCE的,ORACLE提供程序不支持该功能。

    您不必担心指定索引名,oraclesql优化器将自动选择适当的索引(假设存在索引)。

    我还建议您不要使用Microsoft提供的ORACLE提供程序,因为在Framework4.0中不推荐使用它。甲骨文公司的甲骨文供应商非常优秀。

    http://www.oracle.com/technetwork/database/windows/downloads/index-101290.html

        2
  •  0
  •   Dave White John Alexiou    15 年前

    Oracle ADO.NET组件与SQL CE组件不同。我建议把所有的东西都放到 IDbCommand interface 如果您需要能够同时支持这两个提供程序,那么您将获得两个提供程序都需要支持的功能集。如果不需要同时支持这两个提供程序,则只需在Oracle Command对象中找到不同的语法来执行相同的操作。

    推荐文章