In this lineDim da1 As New SqlDataAdapter("SELECT Project_ID,Trade,Fix,Material_Description FROM Mat_e1_prj where mat_sub_no='" + Mat_Sub_NoComboBox.SelectedValue.ToString + "'", con)Dim dt1 As New DataTableda1.Fill(dt1)

1 solution

Solution 1

Ah!then you need to look at Mat_Sub_NoComboBox.SelectedValue.ToString - since it is in the SelectedIndexChanged methoid, the most likely reason is that there is nothing selected. Check the value of Mat_Sub_NoComboBox.SelectedValue at the top of your method - if it is Nothing then you either need to ignore the event, or do something different!

Then there are no matching rows where project_id exactly matches the content of Project_IDTextBox.Text (or similar for your other table)You could check for that as well - DataTable.Rows.Count will tell you.