title: Store values in a table in my database and display the result in a datagrid
body: <p>The SQL query is supposed fetch product id from the products table and through the for loop I'm trying store the values in the product id column of the Inventory table.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>Dim con As New SqlConnection("Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\MAYUR\Desktop\TechUp\Srinath\SrinathDB.mdf;Integrated Security=True;Connect Timeout=30")
  con.Open()
  Dim dsInventory As New DataSet()
  Dim adpInventory = New SqlDataAdapter("Select I.Inventory_Date, P.Product_ID, P.Product_Name, P.Product_Unit,I.Available_Stock From Products P, Inventory I where P.Product_ID = I.Product_ID", con)
  adpInventory.Fill(dsInventory)
  dgInventory.DataSource = dsInventory.Tables(0)
  
  Dim dsProducts As New DataSet()
  Dim adpProducts As New SqlDataAdapter("Select * from Products", con)
  adpProducts.Fill(dsProducts)
  For Each ProductRow As DataRow In dsProducts.Tables(0).Rows
      Dim idval As Integer = Integer.Parse(ProductRow("Product_ID").ToString())
      Dim sqlcomm As New SqlCommand("insert into Inventory(Product_ID) Values(@id)", con)
      sqlcomm.Parameters.Add("@id", SqlDbType.Int).Value = idval
      sqlcomm.ExecuteNonQuery()
  Next
  dgInventory.Refresh()
  </code></pre>