【发布时间】:2015-04-27 07:30:44
【问题描述】:
我是编程新手。我有一个表格(名为personal_Info),它填写一些人的个人数据并将其保存在数据库表Personal_Information中。
2nd 我有另一个表单,它从Personal_Information 搜索并在网格视图中显示结果。
我现在想要:当搜索结果显示在数据网格视图中时,当我双击显示结果的任何一行时,我想要 (personal_info) 打开并在该表单上进行编辑并保存它。
请帮助我。
这是从 sql 获取数据到网格的小代码
SqlConnection strconn = new SqlConnection("server=AAG-PC; Database=humanResource; Integrated Security=sspi");
strconn.Open();
SqlCommand strcmd = new SqlCommand("select * from Personal_Information where "
+ searchComboBx.SelectedItem
+ " like '%" + txtBxKeyword.Text.Trim() + "%'", strconn);
SqlDataAdapter ad = new SqlDataAdapter(strcmd);
DataSet ds = new DataSet ();
ad.Fill(ds);
strconn.Close();
gridViewSearchResult.DataSource = ds.Tables[0];
【问题讨论】:
-
你能展示你尝试了什么吗?
-
这里是从 sql 获取数据到网格的小代码 SqlConnection strconn = new SqlConnection("server=AAG-PC;Database=humanResource;Integrated Security=sspi"); strconn.Open(); SqlCommand strcmd = new SqlCommand("select * from Personal_Information where "+searchComboBx.SelectedItem+" like '%" + txtBxKeyword.Text.Trim() + "%'", strconn); SqlDataAdapter 广告 = 新的 SqlDataAdapter(strcmd);数据集 ds = 新数据集 ();广告填充(ds); strconn.Close(); gridViewSearchResult.DataSource = ds.Tables[0];
标签: c# datagridview