本文整理汇总了C#中System.Data.DataTableReader.GetDateTime方法的典型用法代码示例。如果您正苦于以下问题:C# DataTableReader.GetDateTime方法的具体用法?C# DataTableReader.GetDateTime怎么用?C# DataTableReader.GetDateTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.DataTableReader
的用法示例。
在下文中一共展示了DataTableReader.GetDateTime方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildListBox
//list the log-in sessions according to the selected criterion
private void BuildListBox(int userID, int groupID, DateTime time1, DateTime time2, bool cvs)
{
string pad = " ";
try
{
DataSet sessionData = InternalAdminDB.SelectSessionHistory(userID, groupID, time1, time2);
DataTable sessionHistory = sessionData.Tables[0];
if (sessionHistory.Rows.Count == 0)
{
lblResponse.Text = Utilities.FormatWarningMessage(" No sessions found for your criteria.");
lblResponse.Visible = true;
}
else
{
StringBuilder buf = new StringBuilder();
buf.AppendLine(String.Format("{0,-14}{1,-18}{2,-10}{3,-10}{4,-26}{5,-24}",
"User Name", "Create Time", "End Time","Modify","Group","Client"));
DataTableReader dtr = new DataTableReader(sessionHistory);
while(dtr.Read())
{
//buf.Append(dtr.GetInt64(0) + pad);
buf.Append(String.Format("{0,-12:12}", dtr.GetString(1)) + pad);
if(!dtr.IsDBNull(2))
buf.Append(DateUtil.ToUserTime(dtr.GetDateTime(2),
CultureInfo.InvariantCulture,userTZ,"g") +pad);
else
buf.Append(String.Format("{0,-9:9}", "Not Set") + pad);
if (!dtr.IsDBNull(3))
buf.Append(DateUtil.ToUserTime(dtr.GetDateTime(3), CultureInfo.InvariantCulture, userTZ, "T") + pad);
else
buf.Append(String.Format("{0,-8}", "Not Set") + pad);
if (!dtr.IsDBNull(4))
buf.Append(DateUtil.ToUserTime(dtr.GetDateTime(4), CultureInfo.InvariantCulture, userTZ, "T") + pad);
else
buf.Append(String.Format("{0,-8}", "Not Set") + pad);
string tmp = dtr.GetString(5);
if (tmp != null && tmp.Length > 24)
tmp = tmp.Substring(0, 24);
buf.Append(String.Format("{0,-24}",tmp) + pad);
tmp = dtr.GetString(6);
if (tmp != null && tmp.Length > 24)
tmp = tmp.Substring(0, 24);
buf.Append(String.Format("{0,-24}",tmp));
buf.AppendLine();
}
txtLoginDisplay.Text = buf.ToString();
}
}
catch (Exception ex)
{
lblResponse.Text = Utilities.FormatErrorMessage(" Cannot retrieve UserSessions. " + ex.GetBaseException());
lblResponse.Visible = true;
}
}