[英]help with C# + Oracle 11g
我有这个代码用于快速搜索。 它在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;
}
我尝试像这样转换为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;
}
我得到错误:
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?)
您将需要使用CommandType.Text并创建一个适当的SQL语句以从表MEN中进行选择。 当前正在使用的功能是SQLCE特定的,并且ORACLE提供程序不支持该功能。
您不必担心指定索引名称,ORACLE SQL优化器将自动选择适当的索引,假设存在一个。
我还建议您不要使用Microsoft提供的ORACLE提供程序,因为这在Framework 4.0中已弃用。 Oracle的ORACLE提供商非常好。
ODP.NET- http://www.oracle.com/technetwork/database/windows/downloads/index-101290.html
Oracle ADO.NET组件与SQL CE组件不同。 如果您需要能够支持两个提供程序,并且您将获得两个提供程序都需要支持的功能集,我建议将所有内容都转换为IDbCommand接口 。 如果您不需要同时支持两个提供程序,则只需要在Oracle Command对象中找到不同的语法来执行相同的操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.