我无法将读入strTextLine的内容翻译成个人" VALUES" SQL正在寻找CurrentDb.Execute strSql,dbFailOnError。
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
答案 0 :(得分:0)
编写一个函数将字符串解析为单个字段,然后附加到SQL的VALUES部分。
strSql = funInsertSql(strTextLine) CurrentDb.Execute strSql,dbFailOnError
我是兼职程序员。虽然有人一直这样做可能会帮助或至少参与一些对话来帮助解决。