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


C# DB.Delete方法代码示例

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


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

示例1: DataTableToDB

    protected void DataTableToDB(string _strExcelFileName)//插入操作
    {
       
        EXCELtoSQL ets = new EXCELtoSQL(); 
        DataTable dtExcel = ets.ExcelToDataTable(_strExcelFileName, "Sheet1");
            for (int i = 0; i < dtExcel.Rows.Count; i++)//按行读取
            {

                 //在导入数据库操作之前需要验证数据库与之是否匹配
                string info = "select * from paperApply where id='" + dtExcel.Rows[i][5].ToString() + "'";
                DB db=new DB();
                DataSet ds = db.Select(info, db.DBconn());
                try
                {
                    string title=ds.Tables[0].Rows[0][3].ToString();
                    string kind=ds.Tables[0].Rows[0][4].ToString();
                    string teacher_ID = ds.Tables[0].Rows[0][1].ToString();
                    string teacher_Name = ds.Tables[0].Rows[0][20].ToString();
                    if (title.Equals(dtExcel.Rows[i][6].ToString()) && kind.Equals(dtExcel.Rows[i][7].ToString()) && teacher_ID.Equals(dtExcel.Rows[i][3].ToString()) && teacher_Name.Equals(dtExcel.Rows[i][4].ToString()))
                    {
                    }else{//验证不通过
                        for (int j= 0; j<i; j++)//按行读取
                        {
                        string del="delete from select_Result where student_ID='"+dtExcel.Rows[i][1].ToString()+"'";
                        db.Delete(del,db.DBconn());
                        }//将已经插入的数据删除掉
                        Response.Write("<script language='javascript'>alert('读取的Excel数据中教师" + dtExcel.Rows[i][3].ToString() + dtExcel.Rows[i][4].ToString().Trim() + "所出的论文编号为" + dtExcel.Rows[i][5].ToString() + "的论文题目为" + dtExcel.Rows[i][6].ToString() + ",性质为" + dtExcel.Rows[i][7].ToString() + "的数据与数据库中的数据不一致,导入失败!(在数据库中教师" + teacher_ID + teacher_Name.Trim() + "出的该编号的题目:" + title + ",性质为" + kind + ")');location='finalresults_informationInput.aspx'</script>");
                        break;
                    }

                    // Response.Write("<script language='javascript'>alert('读取的数据为" + dtExcel.Rows[i][0].ToString() + "');</script>");
                    string insert = "insert into select_Result(class,student_ID,student_Name,teacher_ID,teacher_Name,title,grade,paperid,kind)  values('" + dtExcel.Rows[i][0].ToString() +
                        "','" + dtExcel.Rows[i][1].ToString() + "','" + dtExcel.Rows[i][2].ToString().Trim() + "','" + dtExcel.Rows[i][3].ToString() +
                        "','" + dtExcel.Rows[i][4].ToString() + "','" + dtExcel.Rows[i][6].ToString() + "','" + dtExcel.Rows[i][8].ToString() + "','" + dtExcel.Rows[i][5].ToString() + "','" + dtExcel.Rows[i][7].ToString() + "')";

                    bool result = ets.InsertDataToSQL(insert);
                    if (result)
                    {
                        this.Label2.Text = "导入数据库成功!";
                        this.GridView1.Visible = false;
                    }
                    else
                    {
                        this.Label2.Text = "导入数据库失败!可能学号字段重复。";
                    }
                    Panel2.Visible = false;
                    this.Label2.Visible = true;
                }
                catch
                {  
                    Response.Write("<script language='javascript'>alert('读取数据库失败。');</script>");
                }
                finally
                {
                    ds.Clear();
                }
            }

       
    }
开发者ID:zwxscience,项目名称:Paper-management-system,代码行数:60,代码来源:finalresults_informationInput.aspx.cs

示例2: TestDeleteEntryFromDatabase

 public void TestDeleteEntryFromDatabase()
 {
     using (var db = new DB(new Options { CreateIfMissing = true }, "test1.db"))
     {
         db.Put(new WriteOptions(), Slice.FromString("Foo"), Slice.FromString("Bar"));
         Assert.IsNotNull(db.Get(new ReadOptions(), Slice.FromString("Foo")));
         Assert.IsTrue(db.Delete(new WriteOptions(), Slice.FromString("Foo")));
         Assert.IsNull(db.Get(new ReadOptions(), Slice.FromString("Foo")));
     }
 }
开发者ID:maxpert,项目名称:LevelDBWinRT,代码行数:10,代码来源:BasicTests.cs

示例3: TestCRUD

        public void TestCRUD()
        {
            var path = CleanTestDB();

            using (var db = new DB(path, new Options { CreateIfMissing = true }))
            {
                db.Put("Tampa", "green");
                db.Put("London", "red");
                db.Put("New York", "blue");

                Assert.AreEqual(db.Get("Tampa"), "green");
                Assert.AreEqual(db.Get("London"), "red");
                Assert.AreEqual(db.Get("New York"), "blue");

                db.Delete("New York");

                Assert.IsNull(db.Get("New York"));

                db.Delete("New York");
            }
        }
开发者ID:ren85,项目名称:leveldb.net,代码行数:21,代码来源:ReactiveTests.cs

示例4: Main

 public static void Main(string[] args)
 {
     using (var database = new DB("mytestdb", new Options() { CreateIfMissing = true, BloomFilter = new BloomFilterPolicy(10) }))
     {
         database.Put("key1", "value1");
         Assert.AreEqual("value1", database.Get("key1"));
         Assert.IsTrue(database.Get("key1") != null);
         database.Delete("key1");
         Assert.IsFalse(database.Get("key1") != null);
         Assert.IsNull(database.Get("key1"));
     }
 }
开发者ID:ren85,项目名称:leveldb.net,代码行数:12,代码来源:DatabaseTest.cs

示例5: TestReadFromSnapshotOfDatabase

 public void TestReadFromSnapshotOfDatabase()
 {
     using (var db = new DB(new Options { CreateIfMissing = true }, "test1.db"))
     {
         db.Put(new WriteOptions(), Slice.FromString("Foo"), Slice.FromString("Bar"));
         using (var snapshot = db.GetSnapshot())
         {
             var opts = new ReadOptions{ Snapshot = snapshot };
             Assert.IsNotNull(db.Get(opts, Slice.FromString("Foo")));
             Assert.IsTrue(db.Delete(new WriteOptions(), Slice.FromString("Foo")));
             Assert.IsNotNull(db.Get(opts, Slice.FromString("Foo")));
         }
     }
 }
开发者ID:maxpert,项目名称:LevelDBWinRT,代码行数:14,代码来源:BasicTests.cs

示例6: EditPanel_Delete

        private void EditPanel_Delete(object sender, EventArgs e)
        {
            try
            {
                if(Message.Show("هل تريد الحذف", MessageBoxButton.YesNoCancel) == MessageBoxResult.Yes)
                {
                    DB DataBase = new DB("attendence");
                    DataBase.AddCondition("att_id", ((DataRowView)Attendence_DG.SelectedItem)[0]);
                    DataBase.Delete();
                    Fill_DG();
                }
            }
            catch
            {

            }
        }
开发者ID:Enumeg,项目名称:POS-General,代码行数:17,代码来源:Attendence.xaml.cs

示例7: Outcome_EP_Delete

        private void Outcome_EP_Delete(object sender, EventArgs e)
        {
            try
            {
                if(Message.Show("هل تريد الحذف", MessageBoxButton.YesNoCancel, 5) == MessageBoxResult.Yes)
                {
                    DB d = new DB("payments");
                    d.AddCondition("pay_id", ((DataRowView)Outcome_DG.SelectedItem)["pay_id"]);
                    d.Delete();
                    Fill_DG();
                }

            }
            catch
            {


            }
        }
开发者ID:Enumeg,项目名称:POS-General,代码行数:19,代码来源:Loans.xaml.cs

示例8: EditPanel_Delete

        private void EditPanel_Delete(object sender, EventArgs e)
        {
            try
            {
                if(Products_DG.SelectedIndex != -1)
                {

                    if(Message.Show("هل تريد حذف هذا الصنف", MessageBoxButton.YesNoCancel, 5) == MessageBoxResult.Yes)
                    {
                        DB db = new DB("products");
                        db.AddCondition("pro_id", ((DataRowView)Products_DG.SelectedItem)[0]);
                        db.Delete();
                        Fill_Products_LB();

                    }
                }
            }
            catch
            {

            }
        }
开发者ID:Enumeg,项目名称:POS-General,代码行数:22,代码来源:Products.xaml.cs

示例9: EP_Delete

        private void EP_Delete(object sender, EventArgs e)
        {
            try
            {
                if(LB.SelectedIndex != -1)
                {
                if (Message.Show("هل تريد حذف هذا المصروف", MessageBoxButton.YesNoCancel, 10) == MessageBoxResult.Yes)
                {
                    TypeId = LB.SelectedValue;
                    DB db = new DB("outcome_types");
                    db.AddCondition("ott_id", TypeId);
                    db.Delete();
                    Fill_OutCome_Types_LB();
                }
                }
            }
            catch
            {

            }
        }
开发者ID:Enumeg,项目名称:POS-General,代码行数:21,代码来源:OutCome_Types.xaml.cs

示例10: Button6_Click

    protected void Button6_Click(object sender, EventArgs e)
    {
        DB db = new DB();
        //删除学生信息表
        string del="delete from student where grade='"+this.DropDownList6.Text+"'";
        bool student= db.Delete(del, db.DBconn());
        if (student)
        {
            this.deleteMessage.Text = "删除学生信息表中的年级为"+this.DropDownList6.Text+"的数据成功!";
        }
        else
        {
            this.deleteMessage.Text = "删除学生信息表中的年级为" + this.DropDownList6.Text + "的数据失败!";
        }
        //删除选课结果表
        del = "delete from select_Result where grade='" + this.DropDownList6.Text + "'";
        student = db.Delete(del, db.DBconn());
        if (student)
        {
            this.deleteMessage.Text =  this.deleteMessage.Text +"删除选课结果表中的年级为" + this.DropDownList6.Text + "的数据成功!";
        }
        else
        {
            this.deleteMessage.Text = this.deleteMessage.Text + "删除选课结果表中的年级为" + this.DropDownList6.Text + "的数据失败!";
        }
        //删除学生选课表 
        del = "delete from themeSelectedResult where Grade='" + this.DropDownList6.Text + "'";
        student = db.Delete(del, db.DBconn());
        if (student)
        {
            this.deleteMessage.Text = this.deleteMessage.Text + "删除学生选课表中的年级为" + this.DropDownList6.Text + "的数据成功!";
        }
        else
        {
            this.deleteMessage.Text = this.deleteMessage.Text + "删除学生选课表中的年级为" + this.DropDownList6.Text + "的数据失败!";
        }
        int year = DateTime.Now.Year;
        try
        {
             year = Convert.ToInt32(this.DropDownList6.Text) + 4;//毕业年分
        }
        catch
        {
            Response.Write("<script>alert('学生年级选择出错。')</script>");
            return;
        }
        //删除学生任务书
        del = "delete from studentTask where Year='" + year + "'";
        student = db.Delete(del, db.DBconn());
        if (student)
        {
            this.deleteMessage.Text = this.deleteMessage.Text + "删除学生任务书中的毕业年份为为" + year + "的数据成功!";
        }
        else
        {
            this.deleteMessage.Text = this.deleteMessage.Text + "删除学生任务书中的毕业年份为" + year + "的数据失败!";
        }
        //删除开题报告
        del = "delete from STReport where Year='" + year + "'";
        student = db.Delete(del, db.DBconn());
        if (student)
        {
            this.deleteMessage.Text = this.deleteMessage.Text + "删除开题报告中的毕业年份为为" + year + "的数据成功!";
        }
        else
        {
            this.deleteMessage.Text = this.deleteMessage.Text + "删除开题报告中的毕业年份为" + year + "的数据失败!";
        }
        //删除教师课题申请
        del = "delete from paperApply where Year='" + year + "'";
        student = db.Delete(del, db.DBconn());
        if (student)
        {
            this.deleteMessage.Text = this.deleteMessage.Text + "删除教师课题申请中的年份为为" + year + "的数据成功!";
        }
        else
        {
            this.deleteMessage.Text = this.deleteMessage.Text + "删除教师课题申请中的年份为" + year + "的数据失败!";
        }

        //删除中期检查
        del = "delete from midCheck where Year='" + year + "'";
        student = db.Delete(del, db.DBconn());
        if (student)
        {
            this.deleteMessage.Text = this.deleteMessage.Text + "删除中期检查中的年份为为" + year + "的数据成功!";
        }
        else
        {
            this.deleteMessage.Text = this.deleteMessage.Text + "删除中期检查中的年份为" + year + "的数据失败!";
        }

        //删除指导记录
        del = "delete from guiMark where Year='" + year + "'";
        student = db.Delete(del, db.DBconn());
        if (student)
        {
            this.deleteMessage.Text = this.deleteMessage.Text + "删除指导记录中的年份为为" + year + "的数据成功!";
        }
        else
//.........这里部分代码省略.........
开发者ID:zwxscience,项目名称:Paper-management-system,代码行数:101,代码来源:data_Maintain.aspx.cs

示例11: EditPanel_Delete

        private void EditPanel_Delete(object sender, EventArgs e)
        {

            try
            {
                if(Message.Show("هل تريد حذف هذا المحل", MessageBoxButton.YesNoCancel, 10) == MessageBoxResult.Yes)
                {

                    DB db = new DB("points");
                    db.AddCondition("pon_id", Points_LB.SelectedValue);
                    db.Delete();
                    Fill_Point_LB();
                }
            }
            catch
            {

            }
        }
开发者ID:Enumeg,项目名称:POS-General,代码行数:19,代码来源:Points.xaml.cs

示例12: Page_Load


//.........这里部分代码省略.........

        //获取数据
  
            Session["paperid"] = Request.QueryString["paperid"].ToString();
            string paperid = Request.QueryString["paperid"].ToString();
            string tag = "";
            string priority = "";
            try
            {
                tag = Request.QueryString["tag"].ToString();
                priority = Request.QueryString["priority"].ToString();
            }
            catch
            {
            }
      
 //查题*************************************** 
        String sel = "select * from paperApply where id='" + Request.QueryString["paperid"].ToString() + "'";
         ds = db.Select(sel, db.DBconn());
            try
            {  
               
            
                this.Label1.Text = ds.Tables[0].Rows[0][3].ToString();
                Label3.Text = ds.Tables[0].Rows[0][2].ToString();
                Label4.Text = ds.Tables[0].Rows[0][4].ToString();
                Label5.Text = ds.Tables[0].Rows[0][5].ToString();
                Label6.Text = ds.Tables[0].Rows[0][6].ToString();
                Label7.Text = ds.Tables[0].Rows[0][7].ToString();
                String teacher_Name = Convert.ToString(ds.Tables[0].Rows[0][20].ToString());
                Label8.Text = " 教工号:" + Request.QueryString["teacher_ID"] + " 教师姓名:" + teacher_Name;
                this.TextBox1.Text = ds.Tables[0].Rows[0][8].ToString(); ;
                this.TextBox2.Text = ds.Tables[0].Rows[0][9].ToString(); ;
                this.TextBox3.Text = ds.Tables[0].Rows[0][10].ToString();
                this.TextBox4.Text = ds.Tables[0].Rows[0][11].ToString();
                this.TextBox5.Text = ds.Tables[0].Rows[0][12].ToString();
                this.TextBox6.Text = ds.Tables[0].Rows[0][13].ToString();
                int first_select = Convert.ToInt32(ds.Tables[0].Rows[0][17].ToString());
                int second_select = Convert.ToInt32(ds.Tables[0].Rows[0][18].ToString());
                int third_select = Convert.ToInt32(ds.Tables[0].Rows[0][19].ToString());
                this.Label2.Text = "该课题选择情况:第一志愿" + first_select + "人,第二志愿" + second_select + "人,第三志愿" + third_select + "人。";    
                if (tag.Equals("1"))//删除操作
                {
                    string update = "";//初始化更新语句
                    if (priority.Equals("1"))//第一志愿
                    {
                        first_select = Convert.ToInt32(ds.Tables[0].Rows[0][17].ToString());
                        first_select--;
                        update = "update paperApply set first_select='" + first_select + "' where id='" + paperid + "'";//更新选题情况信息
                       
                    }
                    if (priority.Equals("2"))//第二志愿
                    {
                         second_select = Convert.ToInt32(ds.Tables[0].Rows[0][18].ToString());
                        second_select--;
                         update = "update paperApply set second_select='" + second_select + "' where id='" + paperid + "'";//更新选题情况信息
                    }
                    if (priority.Equals("3"))//第三志愿
                    {
                        third_select = Convert.ToInt32(ds.Tables[0].Rows[0][19].ToString());
                        third_select--;
                        update = "update paperApply set first_select='" + third_select + "' where id='" + paperid + "'";//更新选题情况信息
                    }
                     string del="delete from themeSelectedResult where student_ID='"+Session["username"]+"'and priority='"+priority+"'";

                     if (db.Update(update, db.DBconn()) && db.Delete(del, db.DBconn()))
                        
                    {
                            Response.Write("<script>alert('您的课题第" + priority + "志愿删除成功');location='studentSelect.aspx'</script>");
                       
                    }
  
                    else  
                    {
                        Response.Write("<script>alert('您的课题第" + priority + "志愿删除失败');location='studentSelect.aspx'</script>");   
                    }     

                }
               
              
            }
            catch
            {
                Response.Write("<script>alert('数据库出错。');location='studentSelect.aspx'</script>");
            }
            finally
            {
                ds.Clear();
            }

         //判断选题次数\
        String  sel1="select * from themeSelectedResult where student_ID='"+Session["username"]+"'";
        ds = db.Select(sel1, db.DBconn());

        if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 3)
        {
                Button3.Enabled = false;
                Response.Write("<script>alert('你已经选择三个志愿了,不可以再提交。');location='studentSelect.aspx'</script>");
        }  
    }
开发者ID:zwxscience,项目名称:Paper-management-system,代码行数:101,代码来源:studentSelect1.aspx.cs

示例13: TestSnapshot

        public void TestSnapshot()
        {
            var path = CleanTestDB();

            using (var db = new DB(path, new Options { CreateIfMissing = true }))
            {
                db.Put("Tampa", "green");
                db.Put("London", "red");
                db.Delete("New York");

                using (var snapShot = db.CreateSnapshot())
                {
                    var readOptions = new ReadOptions { Snapshot = snapShot };

                    db.Put("New York", "blue");

                    Assert.AreEqual(db.Get("Tampa", readOptions), "green");
                    Assert.AreEqual(db.Get("London", readOptions), "red");

                    // Snapshot taken before key was updates
                    Assert.IsNull(db.Get("New York", readOptions));
                }

                // can see the change now
                Assert.AreEqual(db.Get("New York"), "blue");

            }
        }
开发者ID:ren85,项目名称:leveldb.net,代码行数:28,代码来源:ReactiveTests.cs

示例14: EP_Delete

        private void EP_Delete(object sender, EventArgs e)
        {
            try
            {
                if(LB.SelectedIndex != -1)
                {
                if (Message.Show("هل تريد حذف هذه الوظيفه", MessageBoxButton.YesNoCancel, 10) == MessageBoxResult.Yes)
                {
                    TypeId = LB.SelectedValue;
                    DB db = new DB("jobs");
                    db.AddCondition("job_id", TypeId);
                    db.Delete();
                    Fill_Jobs_LB();
                }
                }
            }
            catch
            {

            }
        }
开发者ID:Enumeg,项目名称:POS-General,代码行数:21,代码来源:jobs.xaml.cs

示例15: Page_Load


//.........这里部分代码省略.........
                    else
                    {
                        Response.Write("<script>alert('对不起,课题修改功能暂未开放。请关注系统公告。');location='Default.aspx'</script>");
                    }
                }
                catch
                {
                    this.Panel2.Visible = false;
                    this.message.Text = "对不起,数据库出错,请联系管理员";
                }
                //二是已经通过审批的数据不可删
               time = "select * from paperApply where id='" + Session["id"] + "'";
                 ds = db.Select(time, db.DBconn());
                try
                {
                    string state1 = ds.Tables[0].Rows[0][14].ToString().Trim();
                    string state2 = ds.Tables[0].Rows[0][15].ToString().Trim();
                    string year2 = ds.Tables[0].Rows[0]["Year"].ToString().Trim();
                    ds.Clear();
                    if (state1.Equals("Y") && state2.Equals("Y"))
                    {
                        this.message.Text = "该课题已被审批通过,无法删除!";
                    }
                
                    //教师课题修改,当课题为往年年份无法修改
                    if (!year2.Equals( Session["year"].ToString()))
                    {
                        this.message.Text = "该课题为往年年份(" + year2 + "年)所出,无法修改!";
                      
                    }
                    else
                    {
                        String del = "delete from paperApply where id='" + Session["id"] + "'";
                        if (db.Delete(del, db.DBconn()))
                        {
                            Response.Write("<script>alert('删除题目为" + title + "的数据成功');location='paperOpe.aspx'</script>");
                        }
                        else
                        {
                            Response.Write("<script>alert('删除题目为" + title + "的数据失败');location='paperOpe.aspx'</script>");

                        }
                    }
                }
                catch
                {
                    this.message.Text = "对不起,数据库出错,请联系管理员";
                }
            }
        }
        catch
        {
            this.message.Text = "出错,参数传递过程可能出错";//出题能无参数传递
        }

        //******************教师出题*******************************************************************
        if (tag.Equals("4"))//出题操作,两个主义要素,一是判断是否在期间,另一个是时间的设定
        {
            this.Panel1.Visible = true;
            this.message.Text = "";
            this.Page.Title = "计软院论文管理系统-教师出题";
            //时间开关判断
            //取值操作和判定开关
            DB db = new DB();
            String time = "select * from time where period='课题申请'";
            DataSet ds = db.Select(time, db.DBconn());
开发者ID:zwxscience,项目名称:Paper-management-system,代码行数:67,代码来源:paperOpe1.aspx.cs


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