本文整理汇总了C#中System.Data.OleDb.OleDbDataReader.GetFieldType方法的典型用法代码示例。如果您正苦于以下问题:C# OleDbDataReader.GetFieldType方法的具体用法?C# OleDbDataReader.GetFieldType怎么用?C# OleDbDataReader.GetFieldType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.OleDb.OleDbDataReader
的用法示例。
在下文中一共展示了OleDbDataReader.GetFieldType方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetDataTypes
public static IDataType[] GetDataTypes(OleDbDataReader reader)
{
List<IDataType> types = new List<IDataType>();
for (int i = 0; i < reader.FieldCount; i++)
{
if (reader.GetFieldType(i) == typeof(string))
{
types.Add(new VarChar(reader.GetName(i), 1000));
}
else
{
types.Add(new Number(reader.GetName(i)));
}
}
return types.ToArray();
}
示例2: StoreColumnTypes
public void StoreColumnTypes(OleDbDataReader Reader)
{
ColumnDataTypes = new DataType[Reader.FieldCount];
for (int i = 0; i < ColumnDataTypes.Length; i++)
{
Type T = Reader.GetFieldType(i);
if (T == Type.GetType("System.String"))
{
ColumnDataTypes[i] = DataType.TypeString;
}
else if (T == Type.GetType("System.DateTime"))
{
ColumnDataTypes[i] = DataType.TypeDate;
}
else
{
ColumnDataTypes[i] = DataType.TypeInt;
}
}
}
示例3: DisplayReader
// Display the result set recursively expanding chapterDepth deep
public void DisplayReader(OleDbDataReader myDataReader, ref uint count, uint alignment, int chapterDepth)
{
try
{
// compute alignment
StringBuilder indent = new StringBuilder((int) alignment);
indent.Append(' ', (int) alignment);
while (myDataReader.Read())
{
// add alignment
StringBuilder row = new StringBuilder(indent.ToString());
// for all columns
for (int i = 0; i < myDataReader.FieldCount; i++)
{
// null columns
if (myDataReader.IsDBNull(i))
{
row.Append("NULL;");
}
else
{
//vector columns
object[] myArray = myDataReader.GetValue(i) as object[];
if (myArray != null)
{
DisplayValue(myArray, row);
}
else
{
//check for chapter columns from "group on" queries
if (myDataReader.GetFieldType(i).ToString() != "System.Data.IDataReader")
{
//regular columns are displayed here
row.Append(myDataReader.GetValue(i));
}
else
{
//for a chapter column type just display the colum name
row.Append(myDataReader.GetName(i));
}
}
row.Append(';');
}
}
if (chapterDepth >= 0)
{
this.ScrubberGUIInst.DebugPrint(row.ToString());
count++;
}
// for each chapter column
for (int i = 0; i < myDataReader.FieldCount; i++)
{
if (myDataReader.GetFieldType(i).ToString() == "System.Data.IDataReader")
{
OleDbDataReader Reader = myDataReader.GetValue(i) as OleDbDataReader;
DisplayReader(Reader, ref count, alignment + 8, chapterDepth - 1);
}
}
}
}
finally
{
myDataReader.Close();
myDataReader.Dispose();
}
}
示例4: DisplayReader
// Display the result set recursively expanding chapterDepth deep
static void DisplayReader(OleDbDataReader myDataReader, ref uint count, uint alignment, int chapterDepth)
{
try
{
// compute alignment
StringBuilder indent = new StringBuilder((int)alignment);
indent.Append(' ', (int)alignment);
while (myDataReader.Read())
{
// add alignment
StringBuilder row = new StringBuilder(indent.ToString());
// for all columns
for (int i = 0; i < myDataReader.FieldCount; i++)
{
// null columns
if (myDataReader.IsDBNull(i))
{
row.Append("NULL\t");
}
else
{
//vector columns
object[] myArray = myDataReader.GetValue(i) as object[];
if (myArray != null)
{
DisplayValue(myArray, row);
}
else
{
//check for chapter columns from "group on" queries
if (myDataReader.GetFieldType(i).ToString() != "System.Data.IDataReader")
{
//regular columns are displayed here
//If (OptPath == false) and colName is System.ItemPathDisplay
//We want to skip Display of this Column
if (!(OptPath == false && myDataReader.GetName(i) == "System.ItemPathDisplay"))
row.Append(myDataReader.GetValue(i));
}
else
{
//for a chapter column type just display the colum name
row.Append(myDataReader.GetName(i));
}
}
row.Append('\t');
}
}
if (chapterDepth >= 0)
{
Console.WriteLine(row.ToString());
count++;
}
// for each chapter column
for (int i = 0; i < myDataReader.FieldCount; i++)
{
if (myDataReader.GetFieldType(i).ToString() == "System.Data.IDataReader")
{
OleDbDataReader Reader = myDataReader.GetValue(i) as OleDbDataReader;
DisplayReader(Reader, ref count, alignment + 8, chapterDepth - 1);
}
}
}
}
finally
{
myDataReader.Close();
myDataReader.Dispose();
}
}
示例5: GetValue
private int GetValue(OleDbDataReader oData)
{
int intValue;
string strFieldType;
strFieldType = Convert.ToString(oData.GetFieldType(0));
switch (strFieldType)
{
case "System.Int16":
intValue = Convert.ToInt32(oData.GetInt16(0));
break;
case "System.Int32":
intValue = oData.GetInt32(0);
break;
case "System.Double":
intValue = Convert.ToInt32(oData.GetDouble(0));
break;
default:
intValue = oData.GetInt32(0);
break;
}
return intValue;
}