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


C# Database.ExecuteNonQuery方法代码示例

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


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

示例1: CreateStoredProcedures

        public static void CreateStoredProcedures(Database db)
        {
            string sql = "create procedure RegionSelect as " +
                "select * from Region Order by RegionId";

            DbCommand command = db.GetSqlStringCommand(sql);
            db.ExecuteNonQuery(command);

            sql = "create procedure RegionInsert (@RegionID int, @RegionDescription varchar(100) ) as " +
                "insert into Region values(@RegionID, @RegionDescription)";

            command = db.GetSqlStringCommand(sql);
            db.ExecuteNonQuery(command);

            sql = "create procedure RegionUpdate (@RegionID int, @RegionDescription varchar(100) ) as " +
                "update Region set RegionDescription = @RegionDescription where RegionID = @RegionID";

            command = db.GetSqlStringCommand(sql);
            db.ExecuteNonQuery(command);

            sql = "create procedure RegionDelete (@RegionID int) as " +
                "delete from Region where RegionID = @RegionID";

            command = db.GetSqlStringCommand(sql);
            db.ExecuteNonQuery(command);
        }
开发者ID:bnantz,项目名称:NCS-V2-0,代码行数:26,代码来源:SqDataSetHelper.cs

示例2: CreateStoredProcedures

        public static void CreateStoredProcedures(Database db)
        {
            DbCommand command;
            string sql;

            sql = "create procedure RegionSelect (cur_OUT OUT PKGENTLIB_ARCHITECTURE.CURENTLIB_ARCHITECTURE) as " +
                "BEGIN OPEN cur_OUT FOR select * from Region Order By RegionId; END;";

            command = db.GetSqlStringCommand(sql);
            db.ExecuteNonQuery(command);

            sql = "create procedure RegionInsert (vRegionID IN Region.RegionID%TYPE, vRegionDescription IN Region.RegionDescription%TYPE) as " +
                "BEGIN insert into Region values(vRegionID, vRegionDescription); END;";

            command = db.GetSqlStringCommand(sql);
            db.ExecuteNonQuery(command);

            sql = "create procedure RegionUpdate (vRegionID IN Region.RegionID%TYPE, vRegionDescription IN Region.RegionDescription%TYPE) as " +
                "BEGIN update Region set RegionDescription = vRegionDescription where RegionID = vRegionID; END;";

            command = db.GetSqlStringCommand(sql);
            db.ExecuteNonQuery(command);

            sql = "create procedure RegionDelete (vRegionID IN Region.RegionID%TYPE) as " +
                "BEGIN delete from Region where RegionID = vRegionID; END;";

            command = db.GetSqlStringCommand(sql);
            db.ExecuteNonQuery(command);
		}
开发者ID:HondaBey,项目名称:EnterpriseLibrary6,代码行数:29,代码来源:OracleDataSetHelper.cs

示例3: btnChangeStatus_OnCommand

 protected void btnChangeStatus_OnCommand(object sender, CommandEventArgs e)
 {
     Database db=new Database();
     db.AddParameter("@id", e.CommandArgument.ToString());
     db.ExecuteNonQuery("update FileComment set Status=1-Status where [email protected]");
     LoadData();
 }
开发者ID:samercs,项目名称:ArchiveSystem,代码行数:7,代码来源:FileCommentList.aspx.cs

示例4: DeleteStoredProcedures

 public static void DeleteStoredProcedures(Database db)
 {
     DbCommand command;
     string sql = "drop procedure RegionSelect";
     command = db.GetSqlStringCommand(sql);
     db.ExecuteNonQuery(command);
     sql = "drop procedure RegionInsert";
     command = db.GetSqlStringCommand(sql);
     db.ExecuteNonQuery(command);
     sql = "drop procedure RegionDelete";
     command = db.GetSqlStringCommand(sql);
     db.ExecuteNonQuery(command);
     sql = "drop procedure RegionUpdate";
     command = db.GetSqlStringCommand(sql);
     db.ExecuteNonQuery(command);
 }
开发者ID:ChiangHanLung,项目名称:PIC_VDS,代码行数:16,代码来源:OracleDataSetHelper.cs

示例5: btnSend_OnClick

    protected void btnSend_OnClick(object sender, EventArgs e)
    {
        if (ValidateData())
        {
            string filename = DateTime.Now.Ticks + "_" + System.IO.Path.GetFileName(fileImage.PostedFile.FileName);
            fileImage.PostedFile.SaveAs(Server.MapPath("~/images/Researchers/")+filename);

            Database db = new Database();
            var lang=new Lang();
            db.AddParameter("@name", txtName.Text);
            db.AddParameter("@countrty", ddlCountry.SelectedValue);
            db.AddParameter("@major", txtMajor.Text);
            db.AddParameter("@level", ddlDegree.SelectedValue);
            db.AddParameter("@Organization", txtWorkPlace.Text);
            db.AddParameter("@Email", txtEmail.Text);
            db.AddParameter("@Phone", txtPhone.Text);
            db.AddParameter("@facebook", txtFacebook.Text);
            db.AddParameter("@Twitter", txtTwitter.Text);
            db.AddParameter("@Linkedin", txtLinkedin.Text);
            db.AddParameter("@Prev", txtPrev.Text);
            db.AddParameter("@Img", filename);
            db.AddParameter("@lang", new Lang().getCurrentLang());

            db.ExecuteNonQuery(
                "insert into Researcher(name,country,major,level,Organization,Email,Phone,facebook,Twitter,Linkedin,Prev,Img,lang) values(@name,@countrty,@major,@level,@Organization,@Email,@Phone,@facebook,@Twitter,@Linkedin,@Prev,@Img,@lang)");

            ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert1", "alertify.alert('" + lang.getByKey("") + "','" + lang.getByKey("ResearchSubmitSuccessfully") + "').set('onok', function(closeEvent){ location.href='/Experts.aspx';} );", true);

        }
    }
开发者ID:samercs,项目名称:NCSS,代码行数:30,代码来源:ResearchersForm.aspx.cs

示例6: btnDelete_OnCommand

 protected void btnDelete_OnCommand(object sender, CommandEventArgs e)
 {
     Database db=new Database();
     db.AddParameter("@id", e.CommandArgument.ToString());
     db.ExecuteNonQuery("delete from UserFav where [email protected]");
     LoadData();
     ShowAlert("تم حذف الملف من قائمة الملفات المفضلة",MsgType.Success);
 }
开发者ID:samercs,项目名称:ArchiveSystem,代码行数:8,代码来源:favorite.aspx.cs

示例7: btnDelete_Command

 protected void btnDelete_Command(object sender, CommandEventArgs e)
 {
     Database db = new Database(); string sql = string.Empty;
     db.AddParameter("@id", e.CommandArgument.ToString());
     db.ExecuteNonQuery("delete from " + tablename + " where id [email protected];delete from ConectedDoc where masterdocid [email protected]");
     ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.success(\"تم الحذف بنجاح.\")</SCRIPT>", false);
     LoadData();
 }
开发者ID:samercs,项目名称:ArchiveSystem,代码行数:8,代码来源:DocumentList.aspx.cs

示例8: AddTestData

 public static void AddTestData(Database db)
 {
     string sql =
         "insert into Region values (99, 'Midwest');" +
             "insert into Region values (100, 'Central Europe');" +
             "insert into Region values (101, 'Middle East');" +
             "insert into Region values (102, 'Australia')";
     DBCommandWrapper testDataInsertion = db.GetSqlStringCommandWrapper(sql);
     db.ExecuteNonQuery(testDataInsertion);
 }
开发者ID:bnantz,项目名称:NCS-V1-1,代码行数:10,代码来源:DB2DataSetHelper.cs

示例9: btnDelete_Command

 protected void btnDelete_Command(object sender, CommandEventArgs e)
 {
     Database db = new Database(); string sql = string.Empty;
     sql = "delete from " + tablename + " where id =" + e.CommandArgument;
     if (db.ExecuteNonQuery(sql) >= 1)
     {
         ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.success(\"تم الحذف بنجاح.\")</SCRIPT>", false);
     }
     LoadData();
 }
开发者ID:samercs,项目名称:ArchiveSystem,代码行数:10,代码来源:SocialList.aspx.cs

示例10: CreateTestDatabase

        public static void CreateTestDatabase(string connectionString, string sqlScriptSource)
        {
            using (var conn = new SqlConnection(connectionString))
            {
                conn.Open();

                var server = new Server(conn);

                var database = new Database(server, "MABMoney_TEST");
                database.Create();

                var schemaSql = File.ReadAllText(sqlScriptSource + @"\all.sql");

                database.ExecuteNonQuery(schemaSql);

                var seedSql = File.ReadAllText(sqlScriptSource + @"\test.sql");

                database.ExecuteNonQuery(seedSql);
            }
        }
开发者ID:markashleybell,项目名称:MABMoney,代码行数:20,代码来源:TestUtils.cs

示例11: btnContactDelete_Click

    protected void btnContactDelete_Click(object sender, EventArgs e)
    {
        Database db = new Database();
        HiddenField id, file;
        ArrayList arrlist = new ArrayList();

        int x = 0;

        foreach (ListViewItem rptItem in RepeaterLists.Items)
        {

            CheckBox chk = (CheckBox)rptItem.FindControl("CheckBox1");
            if (chk.Checked)
            {
                id = (HiddenField)RepeaterLists.Items[x].FindControl("id");
                file = (HiddenField)RepeaterLists.Items[x].FindControl("file");
                if (!string.IsNullOrWhiteSpace(file.Value))
                {
                    System.IO.File.Delete(Server.MapPath("~/SystemFiles/FilesAttach/" + file.Value));
                }
                arrlist.Add(id.Value);

            }
            x++;
        }

        string sql = string.Empty;

        sql = "delete from " + tablename + " where id in (";

        if (arrlist.Count > 0)
        {
            for (int i = 0; i < arrlist.Count; i++)
            {
                if (i == 0)
                {
                    sql += arrlist[i].ToString();
                }
                else
                {
                    sql += "," + arrlist[i].ToString();
                }

            }

            sql += ")";
            if (db.ExecuteNonQuery(sql) >= 1)
            {
                ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.success(\"تم الحذف بنجاح\")</SCRIPT>", false);
            }
            LoadData();
            CheckBox10.Checked = false;
        }
    }
开发者ID:samercs,项目名称:ArchiveSystem,代码行数:54,代码来源:FilesAttachList.aspx.cs

示例12: btnSendMsg_OnClick

 protected void btnSendMsg_OnClick(object sender, EventArgs e)
 {
     Database db = new Database();
     db.AddParameter("@from", DBNull.Value);
     db.AddParameter("@title", txtTitle.Text);
     string msg = "البريد الالكتروني : " + txtEmail.Text + "<br/>";
     msg += txtMsg.Text;
     db.AddParameter("@msg", msg);
     db.ExecuteNonQuery("insert into msg([from],title,msg) values(@from,@title,@msg)");
     ClientScript.RegisterClientScriptBlock(GetType(), "Alert-Msg", "alert('تم ارسال الرسالة الى مدير الموقع');", true);
 }
开发者ID:samercs,项目名称:ArchiveSystem,代码行数:11,代码来源:forgetPassword.aspx.cs

示例13: CreateStoredProcedures

        public static void CreateStoredProcedures(Database db)
        {
            string sql =
                "CREATE PROCEDURE RegionSelect2 () " + Environment.NewLine +
                    "DYNAMIC RESULT SETS 1" + Environment.NewLine +
                    "P1: BEGIN " + Environment.NewLine +
                    "DECLARE cursor1 CURSOR WITH RETURN FOR " + Environment.NewLine +
                    "select * from Region Order by RegionId; " + Environment.NewLine +
                    "OPEN cursor1; " + Environment.NewLine +
                    "END P1";

            DBCommandWrapper command = db.GetSqlStringCommandWrapper(sql);
            db.ExecuteNonQuery(command);

            sql =
                "CREATE procedure RegionInsert2 (IN RegionID INTEGER, IN RegionDescription VARCHAR(100)) " + Environment.NewLine +
                    "P1: BEGIN " + Environment.NewLine +
                    "insert into Region values(RegionID, RegionDescription);" + Environment.NewLine +
                    "END P1";

            command = db.GetSqlStringCommandWrapper(sql);
            db.ExecuteNonQuery(command);

            sql =
                "CREATE procedure RegionUpdate (IN vRegionID INTEGER, IN vRegionDescription VARCHAR(100)) " + Environment.NewLine +
                    "P1: BEGIN " + Environment.NewLine +
                    "update Region set RegionDescription = vRegionDescription where RegionID = vRegionID;" + Environment.NewLine +
                    "END P1";

            command = db.GetSqlStringCommandWrapper(sql);
            db.ExecuteNonQuery(command);

            sql =
                "CREATE procedure RegionDelete2 (IN vRegionID INTEGER) " + Environment.NewLine +
                    "P1: BEGIN " + Environment.NewLine +
                    "delete from Region where RegionID = vRegionID;" + Environment.NewLine +
                    "END P1";

            command = db.GetSqlStringCommandWrapper(sql);
            db.ExecuteNonQuery(command);
        }
开发者ID:bnantz,项目名称:NCS-V1-1,代码行数:41,代码来源:DB2DataSetHelper.cs

示例14: btnDelete_Command

    protected void btnDelete_Command(object sender, CommandEventArgs e)
    {
        // ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.confirm(\"This is a confirm dialog\",function(e){if(e){alertify.success(\"You've clicked OK\")}else{alertify.error(\"You've clicked Cancel\")}});</SCRIPT>", false);
        Database db = new Database(); string sql = string.Empty;

        sql = "delete from " + tablename + " where id =" + e.CommandArgument;

        if (db.ExecuteNonQuery(sql) >= 1)
        {
            ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.success(\"تم الحذف بنجاح.\")</SCRIPT>", false);
        } LoadData();
    }
开发者ID:samercs,项目名称:NCSS,代码行数:12,代码来源:ShowCaseList.aspx.cs

示例15: btnContactDelete_Click

    protected void btnContactDelete_Click(object sender, EventArgs e)
    {
        Database db = new Database();
        HiddenField id, file;
        ArrayList arrlist = new ArrayList();

        int x = 0;

        foreach (ListViewItem rptItem in RepeaterLists.Items)
        {

            CheckBox chk = (CheckBox)rptItem.FindControl("CheckBox1");
            if (chk.Checked)
            {
                id = (HiddenField)RepeaterLists.Items[x].FindControl("id");
                arrlist.Add(id.Value);
            }
            x++;
        }

        string sql = string.Empty,sql2=String.Empty;

        sql = "delete from " + tablename + " where id in (";
        sql2 = "delete from ConectedDoc where masterdocid in (";

        if (arrlist.Count > 0)
        {
            for (int i = 0; i < arrlist.Count; i++)
            {
                if (i == 0)
                {
                    sql += arrlist[i].ToString();
                    sql2 += arrlist[i].ToString();
                }
                else
                {
                    sql += "," + arrlist[i].ToString();
                    sql2 += "," + arrlist[i].ToString();
                }

            }

            sql += ")";
            sql2 += ")";
            db.ExecuteNonQuery(sql + ";" + sql2);
            ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.success(\"تم الحذف بنجاح\")</SCRIPT>", false);

            LoadData();
            CheckBox10.Checked = false;
        }
    }
开发者ID:samercs,项目名称:ArchiveSystem,代码行数:51,代码来源:DocumentList.aspx.cs


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