报错,查询到的表没有数据,你直接引用,就会报错
Dim dr As DataRow = dt2.DataRows(0)
你要加入判断
If dt2.DataRows.Count > 0 Then
End If