public static  bool   UpdateDataTable(string sql)
        {
            string ConnectString = ConfigurationManager.ConnectionString["dataconstr"].ConnectionString; 
            using (SqlConnection con = new SqlConnection(ConnectString))
            {
                try
                {
                    con.Open();
                   
                    
                    SqlCommand comm = new SqlCommand(sql, con);
                    if (comm.ExecuteNonQuery() > 0)                    {
                        return true;
                    }
                    else
                    {
                        return false;
                    }
                   
                }
                catch (SqlException ex)
                {
                    
                    
                    throw new Exception(ex.Message);
                }
            }        }      private void button1_Click(object sender, EventArgs e)
        {
            string a = textBox1.Text.Trim();
            string b = textBox2.Text.Trim();
            if (Validate() )         
           {                string sql = string.Format("insert into 产品 values('{0}','{1}')",a, b);
                if (UpdateDataTable(sql))
                {
                    MessageBox.Show("添加成功", "提示", MessageBoxButtons.OK);
                }
                else
                {
                    MessageBox.Show("添加失败", "提示", MessageBoxButtons.OK);
                }            }
            else
            {
                MessageBox.Show("输入错误,请重新输入!");
            }
           
            
        }以上代码是我要实现向数据库插入数据的操作,我的数据库中的表是设置到主键的,但是当我再插入与表中的主键相同时,这是会出现错误的,请问怎样才能显示出提示信息呢(就是当我插入的数与数据库中的主键相同的值,就会出现提示信息,我就是想用MessageBox.show()提示提示信息),希望能够提供一些参考代码!