SELECT语句包括拼写错误或缺失的保留字或参数名称,或标点符号不正确。错误信息

时间:2014-02-14 04:19:56

标签: visual-studio-2008

非常感谢那些回答我问题的人。我赶时间,所以我现在需要解决这个问题。

这是另一个错误

The SELECT statement includes a reserved word or an argument name that is misspelled or missing, or the punctuation is incorrect

代码如下:

Private Sub RefreshData()
    If Not cnn.State = ConnectionState.Open Then
        cnn.Open()
    End If

    Dim da As New OleDb.OleDbDataAdapter("SELECT txtID as [ID], " & _
                                         "txtLName as [LastName], txtFName as [FirstName], txtMI as [MI] " & _
                                         "txtGender as [Gender], txtDept as [Department], txtNo as [ContactNo]" & _
                                         "txtAddress as [Address], txtEAdd as [EmailAddress], txtYear as [YearEmployed]", cnn)
    Dim dt As New DataTable
    da.Fill(dt)
    Me.dgvProfessorList.DataSource = dt

    cnn.Close()

End Sub

1 个答案:

答案 0 :(得分:1)

您的查询可能有误,您错过了逗号(,)来分隔列。它应该是

 Dim da As New OleDb.OleDbDataAdapter("SELECT [ID],[LastName],[FirstName],[MI],[Gender],[Department],[ContactNo],[Address],[EmailAddress],[YearEmployed] From ProfessorListTable", cnn)