本文介绍了在新搜索后保持datagridview旧结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好,
我有一个datagridview,用sqldataadapter搜索后我用SQL Server表填充值,我的问题是我想在新搜索后保留datagridview中的旧行,现在它删除了旧的结果,我将网格绑定到数据集,这里是代码:
Hello,
I have a datagridview which I fill with values from SQL Server table after a search with sqldataadapter, my problem is that I want to keep older rows in datagridview after a NEW search, now it deletes old results, I have bind the grid to a dataset, here is the code :
SqlConnection2.Open()
SqlDataAdapter7.SelectCommand.Parameters(0).Value = TextBox1.Text
SqlDataAdapter7.Fill(DataSet91, "phones")
Dim dt1 As DataTable = DataSet91.Tables.Item("phones")
Dim rowCustomer1 As DataRow
For Each rowCustomer1 In dt1.Rows
MessageBox.Show("Το Νουμερο τηλεφωνου " + rowCustomer1.Item("telephone").ToString + " κινητο " + rowCustomer1.Item("mobile").ToString, "τηλεφωνα", MessageBoxButtons.OK)
Next
SqlConnection2.Close()
SqlConnection2.Open()
Dim rowCustomer12 As DataRow
If TextBox6.TextLength <> 0 Then
SqlDataAdapter7.SelectCommand.Parameters(0).Value = TextBox6.Text
SqlDataAdapter7.Fill(DataSet91, "phones")
For Each rowCustomer12 In dt1.Rows
MessageBox.Show("Το Νουμερο τηλεφωνου " + rowCustomer12.Item("telephone").ToString + " κινητο " + rowCustomer12.Item("mobile").ToString, "τηλεφωνα", MessageBoxButtons.OK)
Next
End If
SqlConnection2.Close()
它会删除行,即使我将其数据集分配给新的数据表
it deletes rows even if I assign it's dataset to a NEW datatable
推荐答案
这篇关于在新搜索后保持datagridview旧结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!