-1
我無法將讀入strTextLine的內容轉換爲SQL在CurrentDb.Execute strSql,dbFailOnError中查找的單個「VALUES」。通過CurrentDb.Execute將文本字符串寫入表strSql
Public Function ReadTextFile()
Dim objFSO As Object
Dim objTextStream As Object
Dim strTextLine As String
Dim strInputFileName As String, strSql As String, strLine As String, x As Integer
strInputFileName = "F:\Test\Input.txt"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextStream = objFSO.OpenTextFile(strInputFileName)
Do While Not (objTextStream.AtEndOfStream)
strTextLine = objTextStream.ReadLine
If Left(strTextLine, 4) = "1RUN" Then
x = 0
Else
If x < 9 Then
Else
Debug.Print strTextLine, Values
'strSql = "INSERT INTO tmp_tbl_load_loc_match (field1, field 2, etc ..)Values (???"
'CurrentDb.Execute strSql, dbFailOnError
End If
End If
x = x + 1
Loop
objTextStream.Close
Set objFSO = Nothing
Set objTextStream = Nothing
End Function
呃......我不知道你的意思是「不能把什麼讀到字符串中」。請澄清。你想插入什麼,出了什麼問題? –
您的strSql只是完整的SQL命令的第一部分。所有的值都丟失了。因此請閱讀SQL語法。 – Gustav
我知道這些值是空白的,就是我難住的地方。如何將strTextLine分段(轉換)爲值? – Kaw4Life