当前位置: 首页>>代码示例>>C#>>正文


C# Database.ExecuteScalar方法代码示例

本文整理汇总了C#中Database.ExecuteScalar方法的典型用法代码示例。如果您正苦于以下问题:C# Database.ExecuteScalar方法的具体用法?C# Database.ExecuteScalar怎么用?C# Database.ExecuteScalar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Database的用法示例。


在下文中一共展示了Database.ExecuteScalar方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        if(!Page.IsPostBack)
        {
            Database db=new Database();
            var count=db.ExecuteScalar("select count(*) from FileNotice where IsShow=0");
            if (int.Parse(count.ToString()) > 0)
            {
                lblFileNoticeCount.InnerText = String.Format("لديك {0} بلاغ جديد", count.ToString());
            }

            count = db.ExecuteScalar("select count(*) from FileComment where Status=0");
            if (int.Parse(count.ToString()) > 0)
            {
                lblFileCommentCount.InnerText = String.Format("لديك {0} تعليقات غير مفعل", count.ToString());
            }

            count = db.ExecuteScalar("select count(*) from Users where IsActive=0");
            if (int.Parse(count.ToString()) > 0)
            {
                lblUsersCount.InnerText = String.Format("لديك {0} مستخدم غير مفعل", count.ToString());
            }

            count = db.ExecuteScalar("select count(*) from Msg inner join users on (msg.[from]=users.id) where isNull(msg.toid,-1)=-1 and msg.IsRead=0");
            if (int.Parse(count.ToString()) > 0)
            {
                lblMsgCount.InnerText = String.Format("لديك {0} رسالة جديدة", count.ToString());
            }

        }
    }
开发者ID:samercs,项目名称:ArchiveSystem,代码行数:31,代码来源:Default.aspx.cs

示例2: Process

        public override string Process(Database database)
        {
            if (CurrentDatabaseProvider == DatabaseProviders.MySql)
            {
                string columnDefinitionSql = string.Format(@"
SELECT CONCAT(
          CAST(COLUMN_TYPE AS CHAR),
          IF(ISNULL(CHARACTER_SET_NAME),
             '',
             CONCAT(' CHARACTER SET ', CHARACTER_SET_NAME)),
          IF(ISNULL(COLLATION_NAME),
             '',
             CONCAT(' COLLATE ', COLLATION_NAME)),
          ' ',
          IF(IS_NULLABLE = 'NO', 'NOT NULL ', ''),
          IF(IS_NULLABLE = 'NO' AND COLUMN_DEFAULT IS NULL,
             '',
             CONCAT('DEFAULT ', QUOTE(COLUMN_DEFAULT), ' ')),
          UPPER(extra))
  FROM INFORMATION_SCHEMA.COLUMNS
 WHERE TABLE_NAME = '{0}' AND COLUMN_NAME = '{1}'", TableName, OldName);

                var columnDefinition = database.ExecuteScalar<string>(columnDefinitionSql);
                return this.ToString() + " " + columnDefinition;
            }

            return this.ToString();
        }
开发者ID:phaniarveti,项目名称:Experiments,代码行数:28,代码来源:RenameColumnExpression.cs

示例3: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        if(!Page.IsPostBack)
        {
            Database db = new Database();
            DataTable dt0 = db.ExecuteDataTable("select Link from Social");
            if (dt0.Rows.Count > 3)
            {
                Facebook.Attributes.Add("href", dt0.Rows[1][0].ToString());
                Twitter.Attributes.Add("href", dt0.Rows[0][0].ToString());
                Google.Attributes.Add("href", dt0.Rows[2][0].ToString());
                Instagram.Attributes.Add("href", dt0.Rows[3][0].ToString());
            }
            Tools t = new Tools();
            if (t.IsUserLogin(Session))
            {
                Users u = Session["User"] as Users;
                LoadMsg();

                db.AddParameter("@id", u.Id);
                object count = db.ExecuteScalar("select count(*) from msg  where [email protected] and msg.isread=0");
                int tmp;
                if (int.TryParse(count.ToString(), out tmp))
                {
                    if (tmp != 0)
                    {
                        lblMsgCount.InnerText = tmp.ToString();
                    }
                    else
                    {
                        lblMsgCount.InnerHtml = "";
                    }

                }

                UserSesction1.Visible = true;
                UserSection2.Visible = true;
                UserLoginSection1.Visible = false;
            }
            else
            {
                profileLink.Visible = false;
                favLink.Visible = false;
                ProfileLink2.Visible = false;
                FavLink2.Visible = false;

                menu.Attributes["class"] += " extended";
            }

        }
    }
开发者ID:samercs,项目名称:ArchiveSystem,代码行数:51,代码来源:MainMasterPage.master.cs

示例4: RestartTestDatabase

        public static void RestartTestDatabase()
        {
            var database = new Database("Presencia");

            using (var transaction = database.GetTransaction())
            {
                database.Execute("DELETE FROM Pausas;");
                database.Execute("DELETE FROM Jornadas;");
                database.Execute("DELETE FROM UsuariosRoles;");
                database.Execute("DELETE FROM Roles;");
                database.Execute("DELETE FROM Usuarios;");

                // Añadir usuarios y roles
                database.Execute("INSERT INTO Usuarios ([Usuario], [Password]) VALUES (@0, @1)", Usuario, "Prueba");
                database.Execute("INSERT INTO Roles ([Name]) VALUES (@0)", Rol);
                database.Execute("INSERT INTO UsuariosRoles ([Usuario], [Rol]) VALUES (@0, @1)", Usuario, Rol);

                // Añadir jornadas terminadas anteriores al día actual
                var dia = DateTime.Today.AddDays(-NumeroDiasCreados);

                for (var i = 0; i < NumeroDiasCreados; i++)
                {
                    var idJornada = database.ExecuteScalar<int>(
                        "INSERT INTO Jornadas ([Usuario],[Fecha],[Entrada],[Salida]) VALUES (@0, @1, @2, @3);\nSELECT SCOPE_IDENTITY() AS NewID;",
                        Usuario,
                        dia,
                        dia.AddHours(8),
                        dia.AddHours(16));

                    for (var j = 0; j < 4; j++)
                    {
                        var horaInicioPausa = 9 + j;
                        database.Execute(
                        "INSERT INTO Pausas ([IdJornada],[Inicio],[Fin]) VALUES (@0, @1, @2)",
                        idJornada,
                        dia.AddHours(horaInicioPausa),
                        dia.AddMinutes((horaInicioPausa * 60) + 30));
                    }

                    dia = dia.AddDays(1);
                }

                transaction.Complete();
            }
        }
开发者ID:hbiarge,项目名称:Testing-HackLab,代码行数:45,代码来源:DatabaseHelper.cs

示例5: ProcessRequest

        public void ProcessRequest(HttpContext context)
        {
            var accessToken = context.Request["accessToken"].Split('&')[0].Split('=')[1];
            string uid = context.Request["uid"];
            FacebookInteraction.access_token = accessToken;
            context.Session["token"] = accessToken;
            context.Session["uid"] = uid;
            Database database = new Database("b81ca2da-f0ca-4968-b9ef-a147009a4ef4.mysql.sequelizer.com",
                "dbb81ca2daf0ca4968b9efa147009a4ef4", "lizeabvjtqokfima", "qauWLTF4Db7umBPvvyy5LPYAzjLvtFMJKNKnbahQUaN7eEks6ndW4FvHi3vAhkH6");
            MySqlCommand command = database.CreateCommand();
            command.CommandType = System.Data.CommandType.Text;
            string query = "SELECT COUNT(*) FROM facebook.users WHERE user_id = '" + uid + "'";
            database.Open();
            bool isNewUser;
            if (Convert.ToInt32(database.ExecuteScalar(query, command)) == 0)
            {
                query = "INSERT INTO facebook.users VALUES('" + uid + "', '" + accessToken + "', '" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "')";
                isNewUser = true;
            }
            else
            {
                query = "UPDATE facebook.users SET token = '" + accessToken + "' WHERE user_id = '" + uid + "'";
                isNewUser = false;
            }
            database.ExecuteNonQuery(query, command);

            database.Close();
            if (isNewUser)
            {
                context.Response.Redirect("../FirstTimeIndex.aspx");
            }
            else
            {
                context.Response.Redirect("../Search/Search.aspx");
            }
        }
开发者ID:camillu,项目名称:FacebookSearchEngine,代码行数:36,代码来源:LoginHandler.ashx.cs

示例6: ResendPassword

    public static string ResendPassword(string searchBy)
    {
        string retval = string.Empty;
        Database db = new Database(ConnectionManager.GetDatabaseConnectionString());
        SqlParameter p1 = new SqlParameter("Token", ActivationToken);
        SqlParameter p2 = new SqlParameter("EmailAddress", EmailAddress);
        SqlParameter p3 = new SqlParameter("UserName", LoginName);
        SqlParameter p4 = new SqlParameter("SearchBy", searchBy);
        SqlParameter p5 = new SqlParameter("AccountStatus", "0");
        SqlParameter p6 = new SqlParameter("StatusDesc", "");
        p2.Direction = ParameterDirection.InputOutput;
        p5.Direction = ParameterDirection.Output;
        p6.Direction = ParameterDirection.Output;
        object o = db.ExecuteScalar("fb_amad_ResendPassword", p1,p2,p3,p4,p5,p6);
        //return string.Format(o != null ? Convert.ToString(o) : "0");

        retval = Convert.ToString(p5.Value) + ";" + Convert.ToString(p2.Value);
        return retval;
    }
开发者ID:pank1982,项目名称:mydoc,代码行数:19,代码来源:Users.cs

示例7: RegisterUser

 public static string RegisterUser()
 {
     AMADBasePage obj = new AMADBasePage();
     Database db = new Database(ConnectionManager.GetDatabaseConnectionString());
     SqlParameter p1 = new SqlParameter("FirstName", FirstName);
     SqlParameter p2 = new SqlParameter("LastName", LastName);
     SqlParameter p3 = new SqlParameter("EmailAddress", EmailAddress);
     SqlParameter p4 = new SqlParameter("MobileNumber", MobileNumber);
     SqlParameter p5 = new SqlParameter("Token", ActivationToken);
     SqlParameter p6 = new SqlParameter("Password", obj.Encrypt(obj.GeneratePassword(), ConfigurationManager.AppSettings["ENCKI"].ToString()));
     SqlParameter p7 = new SqlParameter("IsPatient", IsPatient);
     SqlParameter p8 = new SqlParameter("Key", ConfigurationManager.AppSettings["ENCKI"].ToString());
     object o = db.ExecuteScalar("fb_amad_RegisterUser", p1, p2, p3, p4, p5, p6, p7, p8);
     return string.Format(o != null ? Convert.ToString(o) : "0");
 }
开发者ID:pank1982,项目名称:mydoc,代码行数:15,代码来源:Users.cs

示例8: ExecuteInsert

 public override object ExecuteInsert(Database db, System.Data.IDbCommand cmd, string PrimaryKeyName)
 {
     db.ExecuteNonQueryHelper(cmd);
     return db.ExecuteScalar<object>("SELECT @@@IDENTITY AS NewID;");
 }
开发者ID:sytelus,项目名称:CCBlog,代码行数:5,代码来源:SqlServerCEDatabaseType.cs

示例9: CreateDoctorsSchedule

    public int CreateDoctorsSchedule()
    {
        Database db = new Database(ConnectionManager.GetDatabaseConnectionString());
        SqlParameter p1 = new SqlParameter("DoctorId", this.DoctorId);
        SqlParameter p2 = new SqlParameter("SchFromDate", this.ScheduleFromDate);
        SqlParameter p3 = new SqlParameter("SchToDate", this.ScheduleToDate);
        SqlParameter p4 = new SqlParameter("AvailableFrom", this.AvailableFrom);
        SqlParameter p5 = new SqlParameter("AvailableTo", this.AvailableTo);
        SqlParameter p6 = new SqlParameter("DoctorCode", this.DoctorCode);
        SqlParameter p7 = new SqlParameter("ScheduleType", this.ScheduleType);
        SqlParameter p8 = new SqlParameter("StatusId", 0);
        SqlParameter p9 = new SqlParameter("StatusDesc", "");
        p8.Direction = ParameterDirection.Output;
        p9.Direction = ParameterDirection.Output;
        object o = db.ExecuteScalar("fb_amad_CreateDoctorsSchedule", p1,p2,p3,p4,p5,p6,p7,p8,p9);
        int stsId = Convert.ToInt32(Convert.ToString(p8.Value));
        string stsDesc = Convert.ToString(p9.Value);

        return stsId;
    }
开发者ID:pank1982,项目名称:mydoc,代码行数:20,代码来源:Doctors.cs


注:本文中的Database.ExecuteScalar方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。