using System;
using System.Collections.Generic;
using System.Text;
using System.Data; //所有的一般数据访问类
using System.Data.Sql; //用于SQL Server数据访问的通用新接口和类
using System.Data.SqlClient; //SQL Server提供程序的类
using System.Data.SqlTypes; //SQL Server数据类型
using System.Data.Odbc;
using System.Configuration; //在项目中要添加对System.Configuration的引用
namespace StudentManagementSystem
{
class c_Binding //数据绑定类
{
//SqlConnection conn = new SqlConnection("server=.;pwd=sun;user id=sa;database=SIM"); //数据库连接
private static string connString = ConfigurationManager.ConnectionStrings["connString"].ConnectionString;
SqlConnection conn = new SqlConnection(connString);
//SqlConnection conn = c_conn.sqlconn(); //调用数据库连接类
SqlCommand cmd = new SqlCommand();
public static DataSet ds = new DataSet();
public static SqlDataAdapter da;
public c_Binding()
{
}
public void DGV_Binding() //绑定tb_AddUserInfo,Frm_UserinfoManagement中的DataGvidView
{
string str_Select = "select 用户名=t_UserName,姓名=t_name,民族=t_Nationality,性别=t_sex,学历=t_Education,学位=t_Degree,所在院系=t_CollegeDepartmentID,政治面貌=t_PoliticsStatus,职称=t_PositionalTitle,所学专业=t_studySpecial,入职时间=t_JObTime,职位=t_Position,身份证号=t_IDCard,固定电话=t_Phone,移动电话=t_MobileTelephone,E_Mail=t_Email,所教专业=t_teachSpecial,备注=t_remarks from tb_AddUserInfo";
da = new SqlDataAdapter(str_Select, conn);
da.Fill(ds, "tb_AddUserInfo");
}
}
}
public void DGV_FillBD()
{
c_Binding UIM_Binding = new c_Binding();
UIM_Binding.DGV_Binding();
this.dGView_UserInfoManagement.DataSource =c_Binding.ds.Tables[0];
}
private void Frm_UserinfoManagement_Load(object sender, EventArgs e)
{
this.DGV_FillBD();
}
private void but_Del_Click(object sender, EventArgs e)
{
c_UIM UIM_UIM = new c_UIM();
if (UIM_UIM.b_Del(lab_name.Text))
{
if (UIM_UIM.b_userDel(lab_name.Text))
{
this.DGV_FillBD();
MessageBox.Show("数据删除成功!");
}
}
}
在but_Del_Click事件中用this.DGV_FillBD()时DataGridView就显示双重数据了
我该怎么改
using System.Collections.Generic;
using System.Text;
using System.Data; //所有的一般数据访问类
using System.Data.Sql; //用于SQL Server数据访问的通用新接口和类
using System.Data.SqlClient; //SQL Server提供程序的类
using System.Data.SqlTypes; //SQL Server数据类型
using System.Data.Odbc;
using System.Configuration; //在项目中要添加对System.Configuration的引用
namespace StudentManagementSystem
{
class c_Binding //数据绑定类
{
//SqlConnection conn = new SqlConnection("server=.;pwd=sun;user id=sa;database=SIM"); //数据库连接
private static string connString = ConfigurationManager.ConnectionStrings["connString"].ConnectionString;
SqlConnection conn = new SqlConnection(connString);
//SqlConnection conn = c_conn.sqlconn(); //调用数据库连接类
SqlCommand cmd = new SqlCommand();
public static DataSet ds = new DataSet();
public static SqlDataAdapter da;
public c_Binding()
{
}
public void DGV_Binding() //绑定tb_AddUserInfo,Frm_UserinfoManagement中的DataGvidView
{
string str_Select = "select 用户名=t_UserName,姓名=t_name,民族=t_Nationality,性别=t_sex,学历=t_Education,学位=t_Degree,所在院系=t_CollegeDepartmentID,政治面貌=t_PoliticsStatus,职称=t_PositionalTitle,所学专业=t_studySpecial,入职时间=t_JObTime,职位=t_Position,身份证号=t_IDCard,固定电话=t_Phone,移动电话=t_MobileTelephone,E_Mail=t_Email,所教专业=t_teachSpecial,备注=t_remarks from tb_AddUserInfo";
da = new SqlDataAdapter(str_Select, conn);
da.Fill(ds, "tb_AddUserInfo");
}
}
}
public void DGV_FillBD()
{
c_Binding UIM_Binding = new c_Binding();
UIM_Binding.DGV_Binding();
this.dGView_UserInfoManagement.DataSource =c_Binding.ds.Tables[0];
}
private void Frm_UserinfoManagement_Load(object sender, EventArgs e)
{
this.DGV_FillBD();
}
private void but_Del_Click(object sender, EventArgs e)
{
c_UIM UIM_UIM = new c_UIM();
if (UIM_UIM.b_Del(lab_name.Text))
{
if (UIM_UIM.b_userDel(lab_name.Text))
{
this.DGV_FillBD();
MessageBox.Show("数据删除成功!");
}
}
}
在but_Del_Click事件中用this.DGV_FillBD()时DataGridView就显示双重数据了
我该怎么改
当知道自己后才知道什么是可怕!