将数据库值与gridview中的值进行比较 [英] Comparing database values with values from a gridview

查看:76
本文介绍了将数据库值与gridview中的值进行比较的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi
i想要将datagridview中填充的值与数据库进行比较

我的代码工作得很好,只测试值是否存在不是所有行datagridview

请帮助



我尝试过的事情:



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

推荐答案

您需要一些上下文。 在网格中有多少个值?



您应该向服务器发送一个列表,INSTEAD为您要查找的每个值创建一个数据读取器。



这就像去杂货店购买ONE ITEM一样;一遍又一遍......
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 ...


这篇关于将数据库值与gridview中的值进行比较的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆