Click here to Skip to main content
15,912,069 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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 :

VB
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
Posted

1 solution

found that I add each datatable row in an unbount datagridview
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900