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


C# SqlDatabase.ExecuteNonQuery方法代码示例

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


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

示例1: Write

 private static void Write(int operationId,int actionId, string information, string creator,int status)
 {
     string sql = string.Empty;
     StringBuilder sb = new StringBuilder();
     SqlDatabase db = new SqlDatabase(ICJSystem.Instance.ConnectionString1);
     try
     {
         Func.AddSqlString(sb, "INSERT INTO OperationLog");
         Func.AddSqlString(sb, "(");
         Func.AddSqlString(sb, "  [Date],");                
         Func.AddSqlString(sb, "  OperationId,");
         Func.AddSqlString(sb, "  ActionId,");
         Func.AddSqlString(sb, "  Information,");
         Func.AddSqlString(sb, "  [Status],");                
         Func.AddSqlString(sb, "  Creator");
         Func.AddSqlString(sb, ")VALUES");
         Func.AddSqlString(sb, "(");
         Func.AddSqlString(sb, "	'" + DateTime.Now.ToString("yyyyMMddHHmmss") + "',");                
         Func.AddSqlString(sb, "	" + operationId + ",");
         Func.AddSqlString(sb, "	" + actionId + ",");
         Func.AddSqlString(sb, "	'" + information + "',");
         Func.AddSqlString(sb, "	" + status + ",");                
         Func.AddSqlString(sb, "	'" + creator + "'");
         Func.AddSqlString(sb, ")");
         sql = sb.ToString();
         db.ExecuteNonQuery(sql);
     }
     catch (Exception ex)
     {
         ApplicationLog.WriteError(ex);
     }            
 }
开发者ID:tuankyo,项目名称:QLTN,代码行数:32,代码来源:OperationLogger.cs

示例2: btnRegister_Click

        protected void btnRegister_Click(object sender, EventArgs e)
        {
            mvMessage.CheckRequired(txtUserName, "Tên Người Dùng(User Name): Mục Bắt Buộc");
            mvMessage.CheckRequired(txtFullName, "Họ Tên: ): Mục Bắt Buộc");
            //mvMessage.CheckRequired(txtEmail, "Emailを正しく入力してください。");

            if (!mvMessage.IsValid) return;
            if (btnRegister.CommandName == "Edit")
            {
                //if (txtConfirm.Text != String.Empty || txtPassword.Text != String.Empty)
                //{
                //    if (txtPassword.Text != txtConfirm.Text)
                //    {
                //        mvMessage.AddError("パスワードが一致していません。");
                //        return;
                //    }
                //    if (!mvMessage.IsValid) return;
                //}

                aspnet_MembershipData data = new aspnet_MembershipData();
                Criteria cri = new Criteria();

                MembershipUser user = Membership.GetUser(UserName);
                cri.And("UserId", "=", user.ProviderUserKey.ToString());
                ITransaction tran = factory.GetSearchObject(data, cri);
                Execute(tran);
                data = (aspnet_MembershipData)(((System.Collections.ArrayList)tran.Result)[0]);

                user.IsApproved = chkActive.Checked;

                user.Email = txtEmail.Text.ToString().Trim();

                try
                {
                    string[] roles = Roles.GetRolesForUser(UserName);
                    bool isExist = false;
                    for (int i = 0; i < roles.Length; i++)
                    {
                        if (ddlRolesList.SelectedValue == roles[i])
                        {
                            isExist = true;
                            break;
                        }
                    }
                    if (!isExist)
                    {
                        if (roles.Length > 0)
                        {
                            Roles.RemoveUserFromRoles(UserName, roles);
                        }
                        Roles.AddUserToRole(UserName, ddlRolesList.SelectedValue);
                    }
                }
                catch (Exception ex)
                {
                    ApplicationLog.WriteError(ex);
                }

                //if (txtPassword.Text != String.Empty)
                //{
                //    try
                //    {
                //        string pass = user.ResetPassword();
                //        txtPassReset.Text = pass;
                //        //if (!user.ChangePassword(pass, txtPassword.Text))
                //        //{
                //        //    mvMessage.AddError("エラーが発生しました。");
                //        //    return;
                //        //}
                //    }
                //    catch
                //    {
                //        mvMessage.AddError("変更パスワード中エラーが発生しました。");
                //    }
                //}

                user.IsApproved = chkActive.Checked;
                user.Email = txtEmail.Text.ToString().Trim();

                Membership.UpdateUser(user);

                //if(  cbManagement.Checked == true)
                //    data.SaleUserFlag = "1";
                //else
                //    data.SaleUserFlag = "0";

                //if (cbInputer.Checked == true)
                //    data.InChargeUserFlag = "1";
                //else
                //    data.InChargeUserFlag = "0";

                string plainQuery = String.Format("UPDATE [aspnet_Membership]  SET [FullName] = '{0}', BuildingId = '{1}'   WHERE [UserID] = '{2}';", txtFullName.Text.Trim(), Func.ParseString(Session["__BUILDINGID__"]), user.ProviderUserKey.ToString());
                SqlDatabase db = new SqlDatabase();
                int Modifieditem = db.ExecuteNonQuery(plainQuery);
                if (Modifieditem == 0)
                {
                    Membership.DeleteUser(txtUserName.Text.Trim());
                    OperationLogger.WriteError(Constants.LogOperationUserId, Constants.LogActionUpdateId, "Lỗi Phát Sinh", Page.User.Identity.Name);
                    mvMessage.AddError("Lỗi Phát Sinh");
                }
//.........这里部分代码省略.........
开发者ID:tuankyo,项目名称:QLTN,代码行数:101,代码来源:EditUser.aspx.cs

示例3: UpdateChangeScript

        private void UpdateChangeScript(int MajorNumber, int MinorNumber, int RevisionNumber, int PatchNumber)
        {
            try
            {

                SqlDatabase db = new SqlDatabase(GetConnectionString());

                string sqlCommand = "_UpdateVersion";
                DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand);

                db.AddInParameter(dbCommand, "MajorNumber", DbType.Int32, MajorNumber);
                db.AddInParameter(dbCommand, "MinorNumber", DbType.Int32, MinorNumber);
                db.AddInParameter(dbCommand, "RevisionNumber", DbType.Int32, RevisionNumber);
                db.AddInParameter(dbCommand, "PatchNumber", DbType.Int32, PatchNumber);


                db.ExecuteNonQuery(dbCommand);
            }
            catch (Exception ex)
            {
                Log(ex, "UpdateChangeScript");
            }

        }
开发者ID:mmooney,项目名称:MMDB.Shared,代码行数:24,代码来源:DBBuildHelper.cs

示例4: ShouldChangeScriptRun

        private bool ShouldChangeScriptRun(int MajorNumber, int MinorNumber, int RevisionNumber, int PatchNumber)
        {
            try
            {

                SqlDatabase db = new SqlDatabase(GetConnectionString());

                string sqlCommand = "_CheckVersion";
                DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand);

                db.AddInParameter(dbCommand, "MajorNumber", DbType.Int32, MajorNumber);
                db.AddInParameter(dbCommand, "MinorNumber", DbType.Int32, MinorNumber);
                db.AddInParameter(dbCommand, "RevisionNumber", DbType.Int32, RevisionNumber);
                db.AddInParameter(dbCommand, "PatchNumber", DbType.Int32, PatchNumber);
                db.AddOutParameter(dbCommand, "ReturnValue", DbType.Int32, 0);

                int DataFoundIndicator = 0;

                db.ExecuteNonQuery(dbCommand);
                DataFoundIndicator = Convert.ToInt32(db.GetParameterValue(dbCommand, "ReturnValue"));

                if (DataFoundIndicator == 0)
                {
                    //This means the previous one was found, but the current one was not.
                    return true;
                }
                if (DataFoundIndicator == 1)
                {
                    //This means the current one was not found.
                    return false;
                }
                if (SkipMissingChangeScripts)
                {
                    //If flag is set to skip,then allow skips....
                    Log("File not found for change script (skipped flag set):  " + String.Format("{0:00}", MajorNumber) + "." +
                        String.Format("{0:00}",MinorNumber) + "." + 
                        String.Format("{0:00}",RevisionNumber) + "." + 
                        String.Format("{0:00}",PatchNumber));

                    return true;
                }
                
                throw (new DBBuildException("A file is found to process, but the previous one was not found as processed. "));
            }
            catch (DBBuildException ex)
            {
                Log(ex, "ChangeScriptRun", "DBBuildException");
                throw (ex);
            }
            catch (Exception ex)
            {
                Log(ex, "ChangeScriptRun");
                return false;
            }

        }
开发者ID:mmooney,项目名称:MMDB.Shared,代码行数:56,代码来源:DBBuildHelper.cs

示例5: ExecuteNonQuery

        //public static int ExecuteNonQuery(string sql)
        //{
        //    SqlDatabase db = new SqlDatabase();
        //    int count = 0;
        //    try
        //    {
        //        count = db.ExecuteNonQuery(sql);
        //        //ApplicationLog.WriteError("SQL: " + sql + " Count: " + count);
        //    }
        //    catch (Exception ex)
        //    {
        //        ApplicationLog.WriteError(ex);
        //        count = 0;
        //    }
        //    return count;
        //}

        public static int ExecuteNonQuery(string sql,string connectionString)
        {
            SqlDatabase db = new SqlDatabase(connectionString);
            int count = 0;
            try
            {
                count = db.ExecuteNonQuery(sql);
            }
            catch (Exception ex)
            {
                ApplicationLog.WriteError(ex);
                count = 0;
            }
            return count;
        }
开发者ID:tuankyo,项目名称:QLTN,代码行数:32,代码来源:DbHelper.cs


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