我想在查询中的DataGridView
where 子句中显示选择查询的结果。条件在标签的值中指定。IE
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