SQL后端冲突机智的前端

SQL后端冲突机智的前端

本文介绍了SQL后端冲突机智的前端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

namespace HotelMGMT
{
    public partial class romdel : Form
    {
        SqlConnection conn = new SqlConnection ("Data Source=NIRAJ;Initial Catalog=Hotel_mgmt2;Integrated Security=yes");
        DataSet ds = new DataSet();
        SqlDataAdapter da = new SqlDataAdapter();
        DataRow dr ;

        public romdel()
        {
            InitializeComponent();
        }

        private void romdel_Load(object sender, EventArgs e)
        {
            textBox1.Focus();
            textBox1.Enabled = true;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            SqlCommand comm = new SqlCommand("select * from Room", conn);
            SqlCommand comm2 = new SqlCommand("delete * from Room where Room_No='" + textBox1.Text + "'", conn);
            if (!string.IsNullOrEmpty(textBox1.Text) == true)
            {
                MessageBox.Show("Please enter the Room No", "Notice");
            }
            SqlCommandBuilder scb = new SqlCommandBuilder(da);
            da.SelectCommand = comm;
            da.Fill(ds, "Room");
            MessageBox.Show(ds.GetXml());

           // da.DeleteCommand = comm2;
            DataTable dt = new DataTable();
            dt = ds.Tables[0];

            foreach (DataRow dr in ds.Tables[0].Select("Room_No = '" + textBox1.Text + "'"))
            {
                dr.Delete();
            }

            MessageBox.Show(ds.GetXml());
            ds.Tables[0].AcceptChanges();
           // da.DeleteCommand = comm2;
            da.Update(ds,"Room");

        }



由于代码部分显示在调试时没有问题,但是所需的行并未在数据库中删除.
帮助.....谢谢si advance



As the code part showing no problem on debug but the desired rows does not get deleted at database.
help..... thank si advance

推荐答案


这篇关于SQL后端冲突机智的前端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-28 09:37