本文整理汇总了C#中DbHelper.ExecuteScalar方法的典型用法代码示例。如果您正苦于以下问题:C# DbHelper.ExecuteScalar方法的具体用法?C# DbHelper.ExecuteScalar怎么用?C# DbHelper.ExecuteScalar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DbHelper
的用法示例。
在下文中一共展示了DbHelper.ExecuteScalar方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
if (Session["uname"] == null)
{
Response.Write("<script>alert('系统超时或非法登录,请重新登录!');window.location.href='default.aspx';</script>");
return;
}
if (Session["uid"]==null)
{
Response.Write("<script>alert('系统超时或非法登录,请重新登录!');window.location.href='default.aspx';</script>");
return;
}
if (Session["ucount"] == null)
{
Response.Write("<script>alert('系统超时或非法登录,请重新登录!');window.location.href='default.aspx';</script>");
return;
}
string uid = Session["uid"].ToString();
dbh = new DbHelper();
string sql;
sql = string.Format("select count(*) from userinfo where parent_id='{0}' ", uid);
DbCommand dbc = dbh.GetSqlStringCommond(sql);
int count=int.Parse(dbh.ExecuteScalar(dbc).ToString());
int usercount = int.Parse(Session["ucount"].ToString()); ;
if (count >= usercount)
{
Response.Write("<script>alert('用户最大数超出设定范围,请联系管理员!');window.location.href='userlist.aspx';</script>");
return;
}
if (Request["id"] != null)
{
id = Request["id"];
sql = string.Format("select * from userinfo where id='{0}' ", Request["id"]);
DbCommand dbc3 = dbh.GetSqlStringCommond(sql);
dbr = dbh.ExecuteReader(dbc3);
dbr.Read();
tb_guid.Text = dbr["guid"].ToString();
tb_memo.Text = dbr["memo"].ToString();
tb_buydate.Text = dbr["buy_date"].ToString();
tb_stopdate.Text = dbr["stop_date"].ToString();
tb_username.Text = dbr["user_name"].ToString();
rb_stop.Checked = dbr["active"].ToString() == "0" ? true : false;
rb_active.Checked = dbr["active"].ToString() == "0" ? false : true;
}
else
{
tb_guid.ReadOnly = false;
tb_buydate.Text = DateTime.Now.ToString("yyyyMMdd");
tb_stopdate.Text = DateTime.Now.AddYears(1).ToString("yyyyMMdd");
rb_stop.Checked = true;
}
}
示例2: CheckOpen
public bool CheckOpen(String Uid)
{
string sql;
dbh = new DbHelper();
sql = string.Format("select count(*) from userinfo where guid='{0}' and active=1", Uid);
DbCommand dbc = dbh.GetSqlStringCommond(sql);
String s = dbh.ExecuteScalar(dbc).ToString();
if (s.Equals("1"))
{
return true;
}
else
{
return false;
}
}
示例3: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
if (Request.Form["uname"] == null)
{
Response.Write("<script>alert('系统超时或非法登录,请重新登录!');window.location.href='default.aspx';</script>");
return;
}
if (Request.Form["psw"] == null)
{
Response.Write("<script>alert('系统超时或非法登录,请重新登录!');window.location.href='default.aspx';</script>");
return;
}
DbHelper dbh = new DbHelper();
string user = Request.Form["uname"];
string psw = Request.Form["psw"];
string sql = "select count(*) as c from admin where [email protected] and [email protected]";
DbCommand cmd = dbh.GetSqlStringCommond(sql);
SqlParameter[] dbp = new SqlParameter[2];
dbp[0] = new SqlParameter();
dbp[0].ParameterName = "@u";
dbp[0].Value = user;
dbp[1] = new SqlParameter();
dbp[1].ParameterName = "@p";
dbp[1].Value = psw;
sql = dbh.ExecuteScalar(cmd, dbp).ToString();
if (sql != "1")
{
Response.Write("<script>alert('用户名密码错误,请重新输入!');window.location.href='default.aspx';</script>");
}
else
{
Session.Timeout = 30;
sql = "select * from admin where username='"+user+"' and password='"+psw +"'";
DbCommand cmd2 = dbh.GetSqlStringCommond(sql);
DbDataReader dr = dbh.ExecuteReader(cmd2);
dr.Read();
Session["uname"] = user;
Session["uid"] = dr["id"].ToString();
Session["ucount"] = dr["usercount"].ToString();
Response.Write("<script> window.location.href='userlist.aspx';</script>");
}
}
示例4: GetRecordCount
public int GetRecordCount(Where @where) {
string sql = $"select count(1) from {Table} where {where.Result};";
using (SqlCommand command = new DbHelper().Command) {
command.CommandText = sql;
command.CommandType=CommandType.Text;
object objCount = command.ExecuteScalar();
return objCount.ToInt();
}
}
示例5: NextIncreaseID
/// summary
/// �����һ��������ID�������ORACLE����һ������
/// /summary
/// param name="sName"�������ֶλ�����/param
/// returns��һ��������ID/returns
public override object NextIncreaseID(string seqName)
{
string selectCommandText = string.Format("SELECT {0}.NEXTVAL FROM DUAL", seqName);
DbHelper helper = new DbHelper();
return helper.ExecuteScalar(selectCommandText);
}
示例6: GetViewText
/// summary
/// ���ָ����ͼ������
/// /summary
/// param name="viewName"��ͼ��/param
/// returns/returns
public override string GetViewText(string viewName)
{
string selectCommandText = "SELECT Text FROM USER_VIEWS WHERE VIEW_NAME='"+viewName+"'";
DbHelper helper = new DbHelper();
return "create or replace view "+viewName+" as " + helper.ExecuteScalar(selectCommandText).ToString();
}
示例7: GetTableComments
/// summary
/// ��������б��ע��
/// /summary
/// returns���ر��ע��/returns
public override string GetTableComments(string tableName)
{
string selectCommandText = @"
select comments
from user_tab_comments
where table_name='{0}'
";
DbHelper helper = new DbHelper();
object o = helper.ExecuteScalar(string.Format(selectCommandText,tableName));
return o == DBNull.Value || o == null ? "" : o.ToString();
}
示例8: GetFieldComments
/// summary
/// ����������ֶε�ע��
/// /summary
/// returns�����ֶε�ע��/returns
public override string GetFieldComments(string tableName,string fieldName)
{
string selectCommandText = @"
select table_name,column_name,
nvl(comments ,column_name) as comments
from user_col_comments
where
table_name = '{0}' and
column_name = '{1}'
";
DbHelper helper = new DbHelper();
object o = helper.ExecuteScalar(string.Format(selectCommandText,tableName,fieldName));
return o == DBNull.Value || o == null ? "" : o.ToString();
}
示例9: ExistView
/// summary
/// �ж��Ƿ���ڶ�Ӧ����ͼ
/// /summary
/// param name="viewName"��ͼ��/param
/// returns���ڷ���true,�����ڷ���fasle/returns
public override bool ExistView(string viewName)
{
string selectCommandText = string.Format("SELECT VIEW_NAME FROM USER_VIEWS WHERE VIEW_NAME = '{0}'", viewName);
DbHelper helper = new DbHelper();
return helper.ExecuteScalar(selectCommandText) != null;
}