title: Compare values in DGV column with database values and add value to new DGV column
body: <p>So, Access database has two columns 1st is seller name (SELLER) and second is it's code (CODE). Access database is database with all SELLER CODEs.</p>
  
  <p>DGV is populated from other source and consists of some of CODEs from Access database.
  DGV has one column with codes.</p>
  
  <p>I would like to create and populate new column (SELLERNAME) in DGV with SELLER names based on DGV codes and Access database CODEs.</p>
  
  <p>I am going to give an example since it's hard for me to explain this better :
  DGV : Column 0, 1st value = 0055, in Access database code 0055 corresponds to the name John
  so I would like to put name "John" in DGV Column1, 1st value, nest to "0055" and so on</p>
  
  <p>Here is my code so far :</p>
  
  <pre><code> DataGridView1.Columns.Add("SELLERNAME", "SELLERNAME") '1
  
      Dim cn As OleDb.OleDbConnection
      Dim cmd As OleDb.OleDbCommand
      Dim odr As OleDb.OleDbDataReader
      Dim strSQL As String
      cn = New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=w:\SCodes.MDB")
  
      strSQL = "SELECT SELLER, CODE FROM SCBASE"
  
      cn.Open()
      cmd = New OleDb.OleDbCommand(strSQL, cn)
      odr = cmd.ExecuteReader(CommandBehavior.CloseConnection)
  
      Do While odr.Read
          For i As Integer = 0 To DataGridView1.Rows.Count - 1
              DataGridView1.Rows(i).Cells(1).Value = odr.GetValue(1).ToString()
          Next
      Loop
  </code></pre>
  
  <p>I don't know what to do next after line <code>For i As Integer = 0 To DataGridView1.Rows.Count - 1</code>.</p>
  
  <p>EDIT :</p>
  
  <p>I think I am close but I need help with one line of code :</p>
  
  <pre><code> Using sqlconn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=w:\SCodes.mdb")
          Using sqlcmd = New OleDbCommand("Select SELLER, CODE From SCBASE Where CODE = @CODE ", sqlconn)
  
              sqlcmd.Parameters.AddWithValue("@CODE ", DataGridView1.Rows(i).Cells(0).Value) 'HOW TO ADD THIS LINE IN LOOP BELOW
  
              sqlconn.Open()
              Dim result = sqlcmd.ExecuteReader()
              Do While (result.Read())
                  For i As Integer = 0 To DataGridView1.Rows.Count - 1
                      DataGridView1.Rows(i).Cells(1).Value = (result("DOBAVLJAC"))
                  Next
              Loop
      End Using
      End Using
  </code></pre>
  
  <p>I had no success with a trial and error. I am trying to put this line <code>sqlcmd.Parameters.AddWithValue("@CODE ", DataGridView1.Rows(i).Cells(0).Value)</code> in loop below but I am getting all sorts of error. </p>