本文整理汇总了C#中System.Data.SqlClient.SqlDataReader.GetDateTimeOffset方法的典型用法代码示例。如果您正苦于以下问题:C# SqlDataReader.GetDateTimeOffset方法的具体用法?C# SqlDataReader.GetDateTimeOffset怎么用?C# SqlDataReader.GetDateTimeOffset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.SqlClient.SqlDataReader
的用法示例。
在下文中一共展示了SqlDataReader.GetDateTimeOffset方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: getTableStringArray
private static List<String[]> getTableStringArray(SqlDataReader reader, SqlString PrintOnlyColumnNameAliasList)
{
DataTable schema = reader.GetSchemaTable();
List<String[]> results = new List<string[]>();
int numCols = schema.Rows.Count;
if (PrintOnlyColumnNameAliasList.ToString().Equals(""))
{
String[] header = new String[numCols];
for (int i = 0; i < numCols; i++)
{
DataRow row = schema.Rows[i];
header[i] = (row["ColumnName"].ToString());
}
results.Add(header);
}
else
{
var colListArray = SplitColumnNameList(ref PrintOnlyColumnNameAliasList);
var unquotedColList = new List<string>();
foreach(var colName in colListArray)
{
if (colName.Length != 0)
{
unquotedColList.Add(colName.Replace("]]", "]"));
}
}
results.Add(unquotedColList.ToArray());
}
while (reader.Read()) {
String[] rowData = new String[numCols];
for (int i = 0; i < reader.FieldCount; i++) {
if (reader.IsDBNull(i)) {
rowData[i] = NULL_STRING;
} else {
SqlDbType dbType = (SqlDbType)schema.Rows[i]["ProviderType"];
switch (dbType) {
case SqlDbType.Date:
rowData[i] = SqlDateToString(reader.GetDateTime(i));
break;
case SqlDbType.SmallDateTime:
rowData[i] = SmallDateTimeToString(reader.GetDateTime(i));
break;
case SqlDbType.DateTime:
rowData[i] = SqlDateTimeToString(reader.GetDateTime(i));
break;
case SqlDbType.DateTime2:
rowData[i] = SqlDateTime2ToString(reader.GetDateTime(i));
break;
case SqlDbType.DateTimeOffset:
rowData[i] = SqlDateTimeOffsetToString(reader.GetDateTimeOffset(i));
break;
case SqlDbType.Decimal:
rowData[i] = reader.GetSqlDecimal(i).ToString();
break;
case SqlDbType.Float:
rowData[i] = reader.GetSqlDouble(i).Value.ToString("0.000000000000000E+0");
break;
case SqlDbType.Timestamp:
case SqlDbType.Image:
case SqlDbType.VarBinary:
rowData[i] = SqlBinaryToString(reader.GetSqlBinary(i));
break;
default:
rowData[i] = reader.GetValue(i).ToString();
break;
}
}
}
results.Add(rowData);
}
return results;
}
示例2: GetDateTimeOffset
public DateTimeOffset GetDateTimeOffset(SqlDataReader reader)
{
InitColumn(reader);
if (reader.IsDBNull(Ordinal))
{
return DateTimeOffset.MinValue;
}
else
{
var date = reader.GetDateTimeOffset(Ordinal);
return date;
}
}
示例3: getTableStringArray
private static List<String[]> getTableStringArray(SqlDataReader reader, SqlString ColumnList)
{
DataTable schema = reader.GetSchemaTable();
List<String[]> results = new List<string[]>();
int numCols = schema.Rows.Count;
if (ColumnList.ToString().Equals(""))
{
String[] header = new String[numCols];
for (int i = 0; i < numCols; i++)
{
DataRow row = schema.Rows[i];
header[i] = row["ColumnName"].ToString();
}
results.Add(header);
}
else
{
results.Add(ColumnList.ToString().Split(','));
}
while (reader.Read()) {
String[] rowData = new String[numCols];
for (int i = 0; i < reader.FieldCount; i++) {
if (reader.IsDBNull(i)) {
rowData[i] = NULL_STRING;
} else {
SqlDbType dbType = (SqlDbType)schema.Rows[i]["ProviderType"];
switch (dbType) {
case SqlDbType.Date:
rowData[i] = SqlDateToString(reader.GetDateTime(i));
break;
case SqlDbType.SmallDateTime:
rowData[i] = SmallDateTimeToString(reader.GetDateTime(i));
break;
case SqlDbType.DateTime:
rowData[i] = SqlDateTimeToString(reader.GetDateTime(i));
break;
case SqlDbType.DateTime2:
rowData[i] = SqlDateTime2ToString(reader.GetDateTime(i));
break;
case SqlDbType.DateTimeOffset:
rowData[i] = SqlDateTimeOffsetToString(reader.GetDateTimeOffset(i));
break;
case SqlDbType.Decimal:
rowData[i] = reader.GetSqlDecimal(i).ToString();
break;
case SqlDbType.Float:
rowData[i] = reader.GetSqlDouble(i).Value.ToString("0.000000000000000E+0");
break;
case SqlDbType.Timestamp:
case SqlDbType.Image:
case SqlDbType.VarBinary:
rowData[i] = SqlBinaryToString(reader.GetSqlBinary(i));
break;
default:
rowData[i] = reader.GetValue(i).ToString();
break;
}
}
}
results.Add(rowData);
}
return results;
}