vb.net access 按条件查询结果DataGridView与文本框中显示的不一致
Private Sub 查询ToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 查询ToolStripButton.Click
Dim MySQLConnectionString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\ZMKJ.accdb;Jet OLEDB:Database Password=123"
Dim MyConnection As New System.Data.OleDb.OleDbConnection(MySQLConnectionString)
MyConnection.Open()
Dim MyDepartmentTable As New Data.DataTable()
Dim MySQL As String = "select * from 通讯录 where (分类='" + Me.分类ToolStripComboBox.Text + "') "
Dim MyAdapter As New OleDbDataAdapter(MySQL, MyConnection)
MyAdapter.Fill(MyDepartmentTable)
Me.通讯录DataGridView.DataSource = MyDepartmentTable
If (MyConnection.State = ConnectionState.Open) Then
MyConnection.Close()
End If
End Sub
请各位大师帮忙,谢谢!