Click here to Skip to main content
16,008,719 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi i want compare value filled in datagridview with database
my code work great and only test if value exist not all rows datagridview
so help please

What I have tried:

cn.Open()
      For j As Integer = 0 To DataGridView1.Rows.Count - 1
          Dim cmd As New SqlCommand("select Codearticle from DetailReceptionFrs where Codearticle='" & DataGridView1.Rows(j).Cells("Article").Value & "' ", cn)
          Using da As SqlDataReader = cmd.ExecuteReader

              While da.Read
                  If da.HasRows Then
                      Form2.Show()
                  Else
                      MsgBox("nnnnnnnnnn")
                  End If
              End While
              da.Close()
          End Using

      Next
Posted
Updated 22-Apr-19 5:39am
Comments

1 solution

You need some context. How many values "in the grid"?

You should send a "list" to the server, INSTEAD of creating a data reader for EVERY value you intend to lookup.

That's like going to the grocery store for ONE ITEM; over and over and over ...
 
Share this answer
 
Comments
Member 14207792 25-Apr-19 4:08am    
i have like 200 values,how i make this list you talked about is it with dataAdapter

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