我目前有一个组合框,选中时会显示每辆车的数据,这是我想要的,但是如何让它再次显示所有数据?
这是代码
Private Sub ComboBox2_SelectionChangeCommitted(sender As Object, e As EventArgs) Handles ComboBox2.SelectionChangeCommitted
If cnn.State = System.Data.ConnectionState.Closed Then
cnn.Open()
End If
Dim sqlquery As String = "select vehiclereg,datereported,defects1,repaired1,defects2,repaired2,defects3,repaired3,datefixed1,datefixed2,datefixed3 from vehicledefects WHERE vehiclereg like '" & Me.ComboBox2.Text & "%'"
Dim sqlcommand As New OleDbCommand
Dim sqladapter As New OleDbDataAdapter
Dim table As New DataTable
With sqlcommand
.CommandText = sqlquery
.Connection = cnn
.ExecuteNonQuery()
End With
With sqladapter
.SelectCommand = sqlcommand
.Fill(table)
End With
Dim ds As New DataSet
sqladapter.Fill(ds, "VehicleDefects")
DataGridView1.DataSource = ds.Tables(0)
cnn.Close()
End Sub