1

对我现在在 VB.net 中所做的事情有疑问。我在 MS 访问中有一个查询,我想在 VB.net 中运行它。我的查询在 MS ACCESS 中运行,但是当我尝试在 VB 中运行它时,它不显示结果。我注意到,当我将 IIF 语句 true 和 false 部分上的数字更改为较低的数字时,它会显示结果。这是我的代码先生/妈妈。

Imports System.Data.OleDb
Public Class Form1
Dim connect As New OleDb.OleDbConnection
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    connect = New OleDb.OleDbConnection
    connect.ConnectionString = "Provider = microsoft.jet.oledb.4.0; data source = E:\Fb1.mdb"
    If Not connect.State = ConnectionState.Open Then
        connect.Open()
    End If

    Dim strSQL As String

    strSQL = "Select * FROM f_7_fSpecies_new WHERE f7Species Like '*iger';"
    Dim ds As New DataSet
    Dim dt As New DataTable
    ds.Tables.Add(dt)
    Dim da As New OleDbDataAdapter

    da = New OleDbDataAdapter("SELECT f7SynonymId, f7Species, Left(f7Species, Len(f7Species)), Right(f7Species, 1), Left(f7Species, Len(f7Species)-IIF(Right(f7Species, 1) In ('a','r'),2,3)) As f7Species_Root " & _
                             "FROM f_7_fSpecies_new " & _
                            "WHERE f_7_fSpecies_new.f7Species Like '*iger'; ", connect)

    da.Fill(dt)
    DataGridView1.DataSource = dt.DefaultView
    Me.DataGridView1.DataSource = dt
    connect.Close()
End Sub

End Class

标准也没有显示结果。

4

0 回答 0