[英]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.