【发布时间】:2012-04-19 15:26:46
【问题描述】:
我想从 DataReader 中按列检索数据。
现在我是这样用的,
AdsCommand cmd = conn.CreateCommand();
cmd.CommandText = "SELECT a,b,c,d FROM testTable";
AdsDataReader reader = cmd.ExecuteReader();
reader.Read();
string columnA = reader.GetValue(0).ToString(); // I want to use column name instead of index number
有没有办法按列名获取数据?喜欢
string columnB = reader["B"].getValue();
谢谢!
【问题讨论】:
-
有一个帖子询问related question about this。如果您好奇,我发布了一些比较这两种访问方法的数字。
标签: asp.net datareader advantage-database-server