DataGridView
クエリ内のwith where 句でselect クエリの結果を表示したい。条件は、ラベルの値で指定されます。すなわち
select *
from hospital_details
where location_name= '" & Label6.Text & "'"
以下はコードです
Public Sub fill()
Try
createConnection()
da = New SqlDataAdapter
Dim c As String
c = Label6.Text
comm.CommandText = "select * from hospital_details where location_name= '" & Label6.Text & "'"
da.SelectCommand = comm
da.Fill(ds, "hospital_details")
DataGridView2.DataSource = ds.Tables(0)
DataGridView2.DataMember = "hospital_details"
DataGridView2.ReadOnly = True
Catch ex As Exception
MsgBox("Error: " & ex.Source & ": " & ex.Message, MsgBoxStyle.OkOnly, "Connection Error !!")
End Try
End Sub
しかし、その表示エラー:NullException