- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我有以下代码,我想遍历此查询结果中的所有字段并填充名为字段的字典。
给定数据读取器这可能吗?
OracleCommand command = connection.CreateCommand();
string sql = "Select * from MYTABLE where ID = " + id;
command.CommandText = sql;
Dictionary<string, string> fields = new Dictionary<string, string>();
OracleDataReader reader = command.ExecuteReader();
最佳答案
你应该能够做这样的事情:
Dictionary<string, string> fields = new Dictionary<string, string>();
OracleDataReader reader = command.ExecuteReader();
if( reader.HasRows )
{
for( int index = 0; index < reader.FieldCount; index ++ )
{
fields[ reader.GetName( index ) ] = reader.GetString( index );
}
}
关于c# - 我如何遍历 OracleDataReader 的所有列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2994539/
与 MS SQL Server 相比,我在从 OracleDataReader 对象读取数据时遇到了一些糟糕的性能。它几乎慢了 10 倍,这是 Not Acceptable 。 下面是两个测试都使用的
代码卡在 OracleDataReader reader = inst.Command.ExecuteReader(); 出现错误 ORA-00911:无效字符(查询中)。我已经分别检查了查询
我正在使用 Oracle.ManagedDataAccess 从我的数据库返回数据,我确实需要对结果进行分页,因为该表中有很多寄存器。 所以我使用了 this 中的第二个答案发布到分页,当我在 Ora
我正在尝试遍历游标。当我直接在 pl/sql 中执行命令(表示为 sql - 见下文)时,我得到了包含更多行的结果集。但是当我运行这段代码时,我只得到一行: using (OracleConnecti
ODP.NET OracleCommand 类有一个 CommandTimeout 属性,可用于强制执行命令超时。此属性似乎适用于 CommandText 是 SQL 语句的情况。示例代码用于说明此属
谁能告诉我如何在 .net 2.0 中从 OracleDataReader 查找行数? 最佳答案 An OracleDataReaderobject represents a forward-only
我试图从 oracal 数据库中获取数据,其中表的列之一是 NUMBER(4,0)。我如何从 C# 中的数据库中获取此数据类型... 这是我试图编译的示例代码 ArrayList ListofSal
我的问题,类似于this one ,如何使用 OracleDataReader 检索给定记录的所有字段?目前,我一直在使用这种方法,它一次只返回一列值: public string Select_Fi
我已经创建了一个软件来从 Oracle DB 读取数据并通过 SMS 发送它,但是当我按下键盘上的 C 键时我想停止 datareader 读取,但是当我这样做时我收到了这个异常消息: Operati
我有以下代码,我想遍历此查询结果中的所有字段并填充名为字段的字典。 给定数据读取器这可能吗? OracleCommand command = connection.Create
当在 c# 程序中使用 OracleDataReader (Oracle.DataAccess.Client) 从记录集中读取数据时,是否存在其中一个字段中的数据类型可以逐行更改(DBNull 除外)
我正在开发我的第一个 ASP.Net 应用程序,似乎遇到了很多障碍(背景主要是 WinForms,最近有一个 MVC5 项目)。 我正在使用 OracleCommand 成功建立我的数据库连接并执行我
我在使用 OracleDataReader(Oracle.DataAccess.Client) 从 Oracle 存储过程输出数据时遇到问题。 程序: procedure LOAD_BL_RE
当我尝试分配读取器时,C# 抛出异常: 无效操作。连接关闭 我尝试从返回单个单元格的查询中获取结果,该单元格中包含平均值。cmd 是一个 oraclecomand,我用它来向表中插入一行,到目前为止一
我有这样的代码, string ConnectionString = ConfigurationManager.ConnectionStrings["ora"].ConnectionString; O
我是一名优秀的程序员,十分优秀!