窗口应用程序中的数据网格视图控件 [英] Data grid view control in window application
问题描述
我正在窗口应用程序中使用数据网格视图控件.我正在使用数据网格视图来填充来自数据库sql server 2005的数据.当第一次绑定数据时,将显示正确的数据.就像....
序号姓名地址DOB
Santosh delhi 1990年1月12日
2 ashok孟买1980年11月10日
但是,当在各个文本框中输入数据并将其保存在数据库中时,同时再次填充数据,然后显示带有先前数据的数据网格视图,并重复数据.如何从数据网格视图中删除重复的数据.
序号姓名地址DOB
Santosh delhi 1990年1月12日
2 ashok孟买1980年11月10日
Santosh delhi 1990年1月12日
2 ashok孟买1980年11月10日
3拉吉夫·金奈2089年2月20日
如何删除数据网格视图中的重复记录?
在第二次调用网格视图之前,尝试在DataGridView
上调用Clear()属性. /blockquote>
尝试:
成功添加新数据后,尝试再次调用该方法.
hi.please in class:
{
公共静态int insert_man(string dore1)
{
如果(Connection.Connect.State == ConnectionState.Open)
{
Connection.Connect.Close();
}
SqlCommand cmd =新的SqlCommand("sp_insert_manegement",Connection.Connect);
cmd.Parameters.Add("@ dore",SqlDbType.NVarChar).Value = dore1;
cmd.CommandType = CommandType.StoredProcedure;
Connection.Connect.Open();
int i = cmd.ExecuteNonQuery();
返回我;
Connection.Connect.Close();
}
}
I am using Data grid view control in window application.I am using data grid view to populate data from data base sql server 2005. when first time data is bind then correct data will show. Like....
SNo. Name Address DOB
1 santosh delhi 12 jan 1990
2 ashok mumbai 10 nov 1980
but when data is entered in various textbox and saved in data base, at the same time again data is populated then data grid view showing with previous data, and data is repeated. how can i remove repeated data from data grid view.
SNo. Name Address DOB
1 santosh delhi 12 jan 1990
2 ashok mumbai 10 nov 1980
1 santosh delhi 12 jan 1990
2 ashok mumbai 10 nov 1980
3 rajiv chennai 20 feb 1089
HOW CAN I REMOVE DUPLICATE RECORD IN DATA GRID VIEW ?解决方案Try calling the Clear() property on theDataGridView
before calling the grid view for second time.
try this:
when you add new data successfully, try to call that method once again.
hi.please written in class:
{
public static int insert_man(string dore1)
{
if (Connection.Connect.State == ConnectionState.Open)
{
Connection.Connect.Close();
}
SqlCommand cmd = new SqlCommand("sp_insert_manegement", Connection.Connect);
cmd.Parameters.Add("@dore", SqlDbType.NVarChar).Value = dore1;
cmd.CommandType = CommandType.StoredProcedure;
Connection.Connect.Open();
int i = cmd.ExecuteNonQuery();
return i;
Connection.Connect.Close();
}
}
这篇关于窗口应用程序中的数据网格视图控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!