本文整理汇总了C#中SqlDatabase.ExecuteScalar方法的典型用法代码示例。如果您正苦于以下问题:C# SqlDatabase.ExecuteScalar方法的具体用法?C# SqlDatabase.ExecuteScalar怎么用?C# SqlDatabase.ExecuteScalar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SqlDatabase
的用法示例。
在下文中一共展示了SqlDatabase.ExecuteScalar方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShowData
/// <summary>
/// List data
/// </summary>
private void ShowData(string PlaceHoldId, string Search)
{
SqlDatabase db = new SqlDatabase();
string sql = string.Empty;
string FullName = string.Empty;
if (Session["__USERFULLNAME__"] != null)
{
FullName = Func.ParseString(Session["__USERFULLNAME__"]);
}
else
{
sql = "SELECT FullName FROM aspnet_Membership "
+ " WHERE UserId=(SELECT UserId FROM aspnet_Users WHERE UserName='" + Page.User.Identity.Name + "')";
FullName = Func.ParseString(db.ExecuteScalar(sql));
Session["__USERFULLNAME__"] = (FullName.Length != 0 ? FullName : Page.User.Identity.Name);
}
ltrFullName.Text = FullName;
divCompose.Visible = false;
divMail.Visible = true;
divReadMail.Visible = false;
hidReply.Value = "0";
string whereString = GetWhere();
sql = string.Empty;
if (!Func.IsValid(ListSortExpression))
{
ListSortExpression = "A.Created";
ListSortDirection = SortDirection.Descending;
}
try
{
int cntInbox = 0;
int cntSentItems = 0;
int cntDraft = 0;
int cntTrash = 0;
int cntSpam = 0;
int cntInboxReadNotYet = 0;
int cntSentItemsReadNotYet = 0;
int cntDraftReadNotYet = 0;
int cntTrashReadNotYet = 0;
int cntSpamReadNotYet = 0;
///////////////////////////////Xe
sql = "Select * from UsersMessagesMapped Where UserName = '" + Page.User.Identity.Name + "' and Delflag = 0";
DataTable dt = new DataTable();
dt = DbHelper.GetDataTable(sql);
foreach (DataRow dr in dt.Rows)
{
string strPlaceHolderID = dr["PlaceHolderID"].ToString();
string IsRead = dr["IsRead"].ToString();
string IsReply = dr["IsReply"].ToString();
switch (strPlaceHolderID)
{
case "1":
cntInbox++;
if ("0".Equals(IsRead))
cntInboxReadNotYet++;
break;
//case "2": cntSentItems++;
// if ("0".Equals(IsRead))
// cntSentItemsReadNotYet++;
// break;
case "3": cntDraft++;
if ("0".Equals(IsRead))
cntDraftReadNotYet++;
break;
case "4": cntTrash++;
//if ("0".Equals(IsRead))
// cntTrashReadNotYet++;
break;
case "5": cntSpam++;
if ("0".Equals(IsRead))
cntSpamReadNotYet++;
break;
default:
break;
}
}
lnkInbox.Text = "Hộp Tin(" + cntInbox + "," + cntInboxReadNotYet + ")";
lnkSent.Text = "Tin Đã Gửi(" + DbHelper.GetCount("Select count(*) from Messages Where UserName = '" + Page.User.Identity.Name + "' and Delflag = 0") + ")";
//lnkDraft.Text = "Tin Đang Soạn(" + cntDraft + "," + cntDraftReadNotYet + ")";
lnkTrash.Text = "Thùng Rác(" + cntTrash + ")";
int count = 0;
string sort = "";
if (!String.IsNullOrEmpty(PlaceHoldId))
{
if ("2".Equals(PlaceHoldId))
{
sql = " SELECT COUNT(*) ";
//.........这里部分代码省略.........
示例2: GetScalar
public static string GetScalar(string sql)
{
SqlDatabase db = new SqlDatabase();
return Func.ParseString(db.ExecuteScalar(sql));
}
示例3: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
string sql = "Select * from UsersMessagesMapped Where UserName = '" + Page.User.Identity.Name + "' and Delflag = 0";
DataTable dtable = new DataTable();
dtable = DbHelper.GetDataTable(sql);
int cntInbox = 0;
int cntInboxReadNotYet = 0;
foreach (DataRow dr in dtable.Rows)
{
string strPlaceHolderID = dr["PlaceHolderID"].ToString();
string IsRead = dr["IsRead"].ToString();
string IsReply = dr["IsReply"].ToString();
switch (strPlaceHolderID)
{
case "1":
cntInbox++;
if ("0".Equals(IsRead))
cntInboxReadNotYet++;
break;
}
}
cntInboxReadNotYet += DbHelper.GetCount("Select count(*) from MessageCommentReadFlg Where UserName = '" + Page.User.Identity.Name + "' and Delflag = 0 and ReadFlag = 0");
lnkInbox.Text = "Tin nhắn(" + cntInboxReadNotYet + ")";
//ltrScript.Text = " <script language=\"javascript\" type=\"text/javascript\" src=\"" + ResolveClientUrl("~/js/common.js") + "\"></script>" +
// "<script language=\"javascript\" type=\"text/javascript\" src=\"" + ResolveClientUrl("~/js/tooltip.js") + "\"></script>";
if (!IsPostBack)
{
DataTable dtR = DbHelper.GetDataTable("Select RoleId from Mst_UserInRoles Where Username = '" + Page.User.Identity.Name + "'");
if (dtR != null)
{
foreach (DataRow row in dtR.Rows)
{
string functionName = row["roleId"].ToString();
if (!mnuMain.UserRoles.Contains(functionName))
mnuMain.UserRoles.Add(functionName);
}
if (Page.User.IsInRole("Administrators"))
{
mnuMain.UserRoles.Add("Administrators");
}
}
mnuMain.DataSource = Server.MapPath("~/MasterPage/MenuData.xml");
mnuMain.DataBind();
//Check latest version
System.Reflection.Assembly asm = System.Reflection.Assembly.GetExecutingAssembly();
string appVer = asm.GetName().Version.ToString();
//get the location of our executing assembly
System.IO.FileInfo inf = new System.IO.FileInfo(asm.Location);
DateTime dt = inf.LastWriteTime;
//ltrLastVersion.Text = "<font size=\"1pt\" color=\"gray\"> 最終メンテナンス: " + dt.ToString("MM/dd HH:mm:ss") + " | バージョン: " + appVer + "</font>";
//if (Page.User.IsInRole(ICJSystem.Instance.RoleLevel1))
//{
// smSource.SiteMapProvider = ICJSystem.Instance.RoleLevel1;
//}
//else if (Page.User.IsInRole(ICJSystem.Instance.RoleLevel2))
//{
// smSource.SiteMapProvider = ICJSystem.Instance.RoleLevel2;
//}
//else if (Page.User.IsInRole(ICJSystem.Instance.RoleLevel3))
//{
// smSource.SiteMapProvider = ICJSystem.Instance.RoleLevel3;
//}
MembershipUser a = Membership.GetUser(Page.User.Identity.Name);
if (a.IsLockedOut)
{
Response.Redirect("Login.aspx");
}
if (Page.User.Identity.Name != null && Page.User.Identity.Name != string.Empty)
{
SqlDatabase db = null;
sql = string.Empty;
string FullName = string.Empty;
string buildingId = string.Empty;
lnkChangePass.OnClientClick = "PopUp('" + ResolveClientUrl("~/ChangePassword.aspx?uid=") + Page.User.Identity.Name + "', " + PopUpChangePassWidth + " , " + PubUpChangePassHeigh + ", 'ChangePassord'); return false;";
try
{
if (Session["__USERFULLNAME__"] != null)
{
FullName = Func.ParseString(Session["__USERFULLNAME__"]);
}
else
{
db = new SqlDatabase();
sql = "SELECT FullName FROM aspnet_Membership "
+ " WHERE UserId=(SELECT UserId FROM aspnet_Users WHERE UserName='" + Page.User.Identity.Name + "')";
FullName = Func.ParseString(db.ExecuteScalar(sql));
Session["__USERFULLNAME__"] = (FullName.Length != 0 ? FullName : Page.User.Identity.Name);
}
ltrFullName.Text = FullName;
//if (Session["__BUILDINGID__"] != null)
//{
// db = new SqlDatabase();
//.........这里部分代码省略.........