title: How to display specific row in datagridview from ms access database in VB
body: <p><a href="https://i.stack.imgur.com/NavkS.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NavkS.jpg" alt="enter image description here"></a></p>
  
  <p>Hi, I am developing a vb project. I have a MS-access database with  3 coloumns(Itno,Name,Price).
  In form i have added two text box and add button (TextBox2=Itno,Textbox=quantity).
  if user give's the Itno and quantity and click the add button,then the Name and price of the Itno should be displayed in the datagridview along with the quantity entered  in the Textbox3.</p>
  
  <p>I have tried as for as my knowledge. But i can not able to display the data in Datagridview. Can any one please help me...</p>
  
  <p>Imports System.Data.OleDb
      Imports System.Data.DataTable</p>
  
  <pre><code>Public Class Form1
      Dim ad As System.Data.OleDb.OleDbDataAdapter
      Dim cm As System.Data.OleDb.OleDbCommand
      Dim co As System.Data.OleDb.OleDbConnection
      Dim dr As System.Data.OleDb.OleDbDataReader
      Dim tb As New DataTable("Table")
  
      Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
          tb.Columns.Add("Iteam", Type.GetType("System.Int32"))
          tb.Columns.Add("Quantity", Type.GetType("System.String"))
          tb.Columns.Add("Price", Type.GetType("System.String"))
          DataGridView1.DataSource = tb
      End Sub
  
      Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
          co = New System.Data.OleDb.OleDbConnection
          co.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;" &amp;
                  "Data Source=C:\Users\Vicky\Desktop\db\bill\bill.mdb;"
          Try
              co.Open()
              Dim cd As String
              cd = "SELECT * FROM item WHERE Itno='" &amp; TextBox2.Text &amp; "'"
              cm = New OleDb.OleDbCommand(cd, co)
              dr = cm.ExecuteReader()
              While dr.Read()
                  Dim n As String
                  Dim p As String
                  p = dr("Price").ToString
                  n = dr("Name").ToString
                  tb.Rows.Add(p.ToString, TextBox3.Text, n.ToString)
                  DataGridView1.DataSource = tb
  
              End While
              co.Close()
          Catch ex As Exception
              MsgBox(ex.ToString)
          End Try
  
      End Sub
  End Class
  </code></pre>