简体   繁体   English

C#和Oracle 11g的帮助

[英]help with C# + Oracle 11g

i have this code for fast search. 我有这个代码用于快速搜索。 it work excellent in sqlCE 它在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;
}

i try to convert to oracle like this: 我尝试像这样转换为oracle:

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;
 }

and i get error: 我得到错误:

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?)

and this error: 而这个错误:

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?)

You will need to use CommandType.Text and create an appropriate SQL statement to select from the table MEN. 您将需要使用CommandType.Text并创建一个适当的SQL语句以从表MEN中进行选择。 The functionality you are currently using is SQLCE specific and is not supported by the ORACLE provider. 当前正在使用的功能是SQLCE特定的,并且ORACLE提供程序不支持该功能。

You should not worry about specifying the index name, the ORACLE SQL optimizer will automatically select the appropriate index, assuming one exists. 您不必担心指定索引名称,ORACLE SQL优化器将自动选择适当的索引,假设存在一个。

I would also suggest that you do not use the Microsoft provided ORACLE provider, since this is deprecated in Framework 4.0. 我还建议您不要使用Microsoft提供的ORACLE提供程序,因为这在Framework 4.0中已弃用。 The ORACLE provider from Oracle is very good. Oracle的ORACLE提供商非常好。

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

The Oracle ADO.NET components are different than the SQL CE components. Oracle ADO.NET组件与SQL CE组件不同。 I would suggest casting everything to an IDbCommand interface if you need to be able to support both providers and you'll get the set of functionality that needs to be supported by both providers. 如果您需要能够支持两个提供程序,并且您将获得两个提供程序都需要支持的功能集,我建议将所有内容都转换为IDbCommand接口 If you don't need to support both providers, you'll just have to find a different syntax to do the same thing in the Oracle Command object. 如果您不需要同时支持两个提供程序,则只需要在Oracle Command对象中找到不同的语法来执行相同的操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM