Winform 在datagridview控件中增删改的源码
如题,哪位大哥大姐有比较完整的源码发给小弟peijiping@sina.com。急用谢谢。50分奉上!!!...
如题,哪位大哥大姐有比较完整的源码发给小弟peijiping@sina.com。急用谢谢。50分奉上!!!
展开
4个回答
展开全部
//删除
private void 删除用户ToolStripMenuItem_Click(object sender, EventArgs e)
{
string UserId = dgvUserInfo.SelectedRows[0].Cells[0].Value.ToString();
string delete = "delete from 用户表 where 用户编号=" + UserId;
bb.Connection = aa;
bb.CommandText = delete;
aa.Open();
bb.ExecuteNonQuery();
aa.Close();
dgvUserInfo.Rows.Remove(dgvUserInfo.SelectedRows[0]);
}
//增加
List<User> list = new List<User>();
string UserName = txtUserName.Text;
string UserPsw = txtUserPsw.Text;
string UserRight = txtUserRight.Text;
string Sql = "insert 用户表(用户名,密码,权限) values('"+UserName+"','"+UserPsw+"','"+UserRight+"')";
SqlConnection aa = new SqlConnection("Data Source=ST412\\SQLEXPRESS;Initial Catalog=44;Integrated Security=True");
SqlCommand bb = new SqlCommand();
bb.Connection = aa;
bb.CommandText = Sql;
aa.Open();
bb.ExecuteNonQuery();
private void 删除用户ToolStripMenuItem_Click(object sender, EventArgs e)
{
string UserId = dgvUserInfo.SelectedRows[0].Cells[0].Value.ToString();
string delete = "delete from 用户表 where 用户编号=" + UserId;
bb.Connection = aa;
bb.CommandText = delete;
aa.Open();
bb.ExecuteNonQuery();
aa.Close();
dgvUserInfo.Rows.Remove(dgvUserInfo.SelectedRows[0]);
}
//增加
List<User> list = new List<User>();
string UserName = txtUserName.Text;
string UserPsw = txtUserPsw.Text;
string UserRight = txtUserRight.Text;
string Sql = "insert 用户表(用户名,密码,权限) values('"+UserName+"','"+UserPsw+"','"+UserRight+"')";
SqlConnection aa = new SqlConnection("Data Source=ST412\\SQLEXPRESS;Initial Catalog=44;Integrated Security=True");
SqlCommand bb = new SqlCommand();
bb.Connection = aa;
bb.CommandText = Sql;
aa.Open();
bb.ExecuteNonQuery();
展开全部
DataGridView增删改示例:http://www.veisun.com/09/2009-06/NewInfo-4036.html
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
我这有
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
我有批量增删改,baiduhi号:wan_shan
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询