Board logo

標題: [發問] rs.Open strsql, cn問題請教 [打印本頁]

作者: rouber590324    時間: 2018-1-5 10:39     標題: rs.Open strsql, cn問題請教

DEAR  ALL 大大
1.執行圖一程式出現
  執行階段錯誤2147217900(80040E14)
  FROM KEYWORD NOT FOUND WHRER EXPECTED
1.1 BUG出停於  rs.Open strsql, cn
2.請問各位大大問題點於何處??煩不吝賜教  THANKS*10000

圖一
Sub BY_PN()
    Range("B2:IV65536").ClearContents
    Dim cn As New ADODB.Connection
    Dim rs As New ADODB.Recordset
    Dim strsql As String
    cn.Open "Provider=MSDAORA.1;Password=BATCH;User ID=URCE01B;Data Source=QSRS05A"
    A = 2
    Do Until Range("A" & A) = ""
        PN = Range("A" & A)
        If IsNumeric(Mid(PN, 2, 1)) Then pntyp = "PN_S" Else pntyp = "PN"
        strsql = "SELECT VWDD5013_2.MTNO,VWDD5013_2.THK,VWDD5013_2.CUTHK,VWDD5013_3.MTKND,VWDD5013_3.MTNO,VWDD5013_3.MTTHK Chr(13) & "" & Chr(10)" _
               & "FROM VWDD5013_2,VWDD5013_3" & Chr(13) & "" & Chr(10) _
               & "Where VWDD5013_2.PN=VWDD5013_3.PN and A." & pntyp & " ='" & PN & "'"
        rs.Open strsql, cn
        Range("B" & A).CopyFromRecordset rs
        rs.Close
        A = A + 1
    Loop
    cn.Close
'代號轉選項
End Sub




歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)