title: Data retreving from two tables depending on other column data
body: <p>here i have the company name combo box.. where user sekects the name..
  i want the company name to be displayed in the grid... but as per the table there is a company code column only....</p>
  
  <p>i should display table division data with company name in company table 
  there is company code common for both the tables...</p>
  
  <p>i have done this till now.. but getting errors...</p>
  
  <pre class="lang-vb prettyprint-override"><code>Private Sub btnDivUpdate_Click(ByVal sender As System.Object, ByVal e As  
         System.EventArgs) Handles btnDivUpdate.Click
  
      Dim con As New SqlConnection("Data Source")
      con.Open()
      Dim cmd As New SqlCommand("update tblDivision set tblCompany.CompanyName='" &amp; 
           cmbDivComName.Text &amp; "',tblDivision.Description1='" &amp; txtDivDesc.Text &amp; "',     
           tblDivision.DivSeq='" &amp; txtDivSeq.Text &amp; "', tblDivision.CreatedBy ='" &amp;           
           txtDivCreatedBy.Text &amp; "', tblDivision.CreatedDate ='" &amp; 
           txtDivCreatedDate.Text &amp; "', tblDivision.LastModifiedBy ='" &amp;   
           txtDivLastModifiedBy.Text &amp; "', tblDivision.LastModifiedDate ='" &amp; 
           txtDivLastModifiedDate.Text &amp; "' JOIN tblCompany ON tblDivision.CompanyCode = 
           tblCompany.CompanyCode where DivisionCode ='" &amp; cmbDivCode.Text &amp; "' ", con)
  
      cmd.CommandType = CommandType.Text
      cmd.ExecuteNonQuery()
      Dim cmd2 As New SqlCommand("select * from tblDivision", con)
      Dim da2 As New SqlDataAdapter(cmd2)
      Dim ds2 As New DataSet()
      da2.Fill(ds2,
         "tblDivision")
      DataGridDivision.DataSource = ds2.Tables(0)
      con.Close()
  End Sub
  </code></pre>
  
  <p>can any one help.........</p>