本文整理汇总了C#中System.Data.DataTableReader.Item属性的典型用法代码示例。如果您正苦于以下问题:C# DataTableReader.Item属性的具体用法?C# DataTableReader.Item怎么用?C# DataTableReader.Item使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。
在下文中一共展示了DataTableReader.Item属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DisplayItems
private static void DisplayItems(DataTableReader reader)
{
int rowNumber = 0;
while (reader.Read())
{
Console.WriteLine("Row " + rowNumber);
for (int i = 0; i < reader.FieldCount; i++)
{
Console.WriteLine("{0}: {1}", reader.GetName(i), reader[i]);
}
rowNumber++;
}
}
示例2: GetValueByName
private static object GetValueByName(
DataTableReader reader, string columnName)
{
// Consider when to use a procedure like this one carefully:
// if you're going to retrieve information from a column
// in a loop, it would be better to retrieve the column
// ordinal once, store the value, and use the methods
// of the DataTableReader class directly.
// Use this string-based indexer sparingly.
object columnValue = null;
try
{
columnValue = reader[columnName];
}
catch (ArgumentException ex)
{
// Throw all other errors back out to the caller.
columnValue = null;
}
return columnValue;
}