Visual Basic Access:参数太少.预计1


    Private Sub createSequenceDataFiles_Sequence(sPath As String, sTableName As String, iSeqNo As Integer)
        Dim RST As DAO.Recordset
        Dim nIL As Long, nLastIL As Long
        Dim sSQL As String
        '
        ' Get the data from the table
        '
        sSQL = _
    " SELECT [“ & sTableName & “].IL, “ & _
    “ [XL]-[FIRST_XL]+1 AS XL_IDX, “ & _
    “ [“ & sTableName & “] “ & _
    “ FROM [“ & sTableName & “] “ & _
    “ INNER JOIN TBL_FIRST_XL_FOR_IL “ & _
    “ ON [“ & sTableName & “].IL = TBL_FIRST_XL_FOR_IL.IL “ & _
    “ ORDER BY [“ & sTableName & ”].IL, [XL]-[FIRST_XL]+1”
        Set RST = CurrentDb.OpenRecordset(sSQL)
        While Not RST.EOF
            nIL = RST("IL").Value
            If Not (nLastIL = nIL) Then
                '
                ' If we've already done one, close the file
                '
                If nLastIL > 0 Then Close #1
                '
                ' Open the file for the current in-line
                '
                Open sPath & "WBS1IL_" & Format(nIL, "0000") & ".pks" For Append As 1
            End If
            '
            ' Write the data
            '
            Write #1, iSeqNo, RST(“XL_IDX”).value + 1, RST("TIME").Value
            nLastIL = nIL
            RST.MoveNext
        Wend
        '
        ' Close
        '
        Set RST = Nothing
        Close
    End Sub

我得到这个错误

这有什么问题吗?

这是整个代码,现在我很确定这是SQL位这是问题,也许我的表名是错误的

SQL查询中的表和/或字段名与数据库结构不匹配。

包括sTableName参数中的任何值。

只要检查并确保所有字段完全匹配,你就应该找到罪魁祸首。

EDIT:刚刚注意到在SELECT部分

    “ [“ & sTableName & “] “ & _

你不应该在语句的SELECT部分引用整个表,如果你从SQL语句中删除这一行会发生什么?

相关内容

最新更新