解决了!我只是在某些领域进行了实验,我不知道究竟是什么解决了这个问题。:) 首先,我将表格字段的所有数据类型从数字更改为文本。其次,我修改了form2_load和combobox_selectedindexchanged中的一些代码。
前:
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    con.ConnectionString = "provider=microsoft.ace.oledb.12.0;data source = ..\Accounting2.accdb"
    con.Open()
    ComboBox1.SelectedIndex = 0
    sSqlUser = "SELECT df, sdf, asdf FROM tbl_login ORDER BY df"
    sSqlProduct = "SELECT cv, xcv, zxcv FROM tbl_product ORDER BY cv"
    sSqlTransaction = "SELECT rt, ert, wert, qwert FROM tbl_transaction ORDER BY rt"
    sSql = sSqlUser
    Call FillList()
    Dim dt As New DataTable
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
    If ComboBox1.SelectedIndex = 0 Then
        sSql = sSqlUser
    ElseIf ComboBox1.SelectedIndex = 1 Then
        sSql = sSqlProduct
    ElseIf ComboBox1.SelectedIndex = 2 Then
        sSql = sSqlTransaction
    End If
End Sub
然后:
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    con.ConnectionString = "provider=microsoft.ace.oledb.12.0;data source = ..\Accounting2.accdb"
    con.Open()
    sSqlUser = "SELECT df, sdf, asdf FROM tbl_login ORDER BY df"
    sSqlProduct = "SELECT cv, xcv, zxcv FROM tbl_product ORDER BY cv"
    sSqlTransaction = "SELECT rt, ert, wert, qwert FROM tbl_transaction ORDER BY rt"
    ComboBox1.SelectedIndex = 0
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
    If ComboBox1.SelectedIndex = 0 Then
        sSql = sSqlUser
    ElseIf ComboBox1.SelectedIndex = 1 Then
        sSql = sSqlProduct
    ElseIf ComboBox1.SelectedIndex = 2 Then
        sSql = sSqlTransaction
    End If
    Call FillList()
    Dim dt As New DataTable
End Sub