标题:ComboBox与数据库绑定后同步问题
取消只看楼主
王子归来
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2008-8-14
 问题点数:0 回复次数:0 
ComboBox与数据库绑定后同步问题
一个按纽 负责删除 ComboBox(手动连接数据库) 选中的内容
按完删除后, ComboBox 选中的内容没有被即时删除(数据库中已经删除)
等再一次打开软件后, ComboBox 刚刚选中的内容才被删除
按纽的代码:
       private void delete_Click(object sender, EventArgs e)
        {
                string str1 = "Data Source=.;Initial Catalog=prince;Integrated Security=True";
                try
                {
                    SqlConnection conn = new SqlConnection(str1);
                    conn.Open();
                    string sql = "delete from Song where Address=" +"'"+comboBox1.Text.ToString()+"'";
                    SqlCommand cmd = new SqlCommand(sql, conn);
                    int i = cmd.ExecuteNonQuery();
                    conn.Close();
                    if (i > 0)
                    {
                        MessageBox.Show("You Had Deleted" + comboBox1.Text.ToString());
                    }
                    else
                    {
                        MessageBox.Show("Delete fail");
                    }
                }
                catch (SystemException ex)
                {
                    MessageBox.Show("Error:" + ex.Message);
                }
        }
强调一下  ComboBox手动连接数据库
搜索更多相关主题的帖子: ComboBox 数据库 绑定 delete string 
2008-08-14 21:49



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-228334-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.613234 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved