最近需要將大的txt檔案讀取出每一條記錄,并插入資料庫中,使用普通讀取方法,運行時程式竟然卡死了,請問各位高手,如何能順利讀取出記錄。
卡死程式:
Private Sub Command4_Click()
Open "d:\i31\011D.txt" For Input As #1
Dim b As String
Dim s() As String
Set cn = New ADODB.Connection
strcon = "Provider=SQLOLEDB.1;Password=password;Persist Security Info=True;User ID=ad;Initial Catalog=TJ;Data Source=22.39.128.153"
cn.ConnectionString = strcon
cn.Open
Do While Not EOF(1)
Line Input #1, b
s = Split(b, "|")
Sql = "insert into 。。。"
cn.Execute (Sql)
Loop
Close 1
MsgBox "匯入完成"
End Sub
uj5u.com熱心網友回復:
…………doevents
Loop
資料量大卡死是必然的,用progressbar顯示進度
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/258241.html
標籤:VB基礎類
