0
我有一段代码将数据从文本文件导入到Access中的表格。文本文件中的每一行都应该单独保存在表格中,但有时我在表格中有一个重复的行。比如我有一个文本文件是这样的:插入后在表格中重复行
Water
Bird
Summer
有时候,不要总是我看到两个Summer
在表中。总是文本文件的最后一行重复。
这里是我的VB代码:
Private Sub Command11_Click()
Dim ifile As Integer
Dim db As Database
Dim name As String
Let ifile = FreeFile
name = util1.fDateiName("*.lab", "Lable")
Me.RecordSource = ""
DoCmd.RunSQL ("DELETE * FROM tb_lable_Daten")
Me.RecordSource = "SELECT name FROM tb_lable_Daten"
If name <> "" Then
Open name For Input As ifile
While Not EOF(ifile)
Line Input #ifile, entireline
'MsgBox entireline
DoCmd.RunSQL ("INSERT INTO tb_lable_Daten (name) VALUES ('" & entireline & "');")
Wend
List5.Requery
List5.SetFocus
MsgBox ("Die Daten sind erfolgreich gespeichert")
End If
End Sub
我怎样才能解决这个问题?为什么会出现这个问题?