1070行数据高速合并进系统后,用FOXTABLE保存非常慢,搜索论坛后,发现了以下办法http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=52855&authorid=0&page=0&star=1
但我照写代码后,保存依然很慢,1070行数据要116秒,不清楚是什么原因,请老师指正。
其中因我的ID是自增列,所以在原代码基础上加了个IF判断,如果列名为ID,就不合并进SQL语句。
Dim dt As Date = Date.Now
Dim cmd As New SQLCommand
cmd.C
Dim sql1,sql2 As String
For Each c As Col In Tables("上年实际数导入").Cols
If c.Name<>"ID" Then
sql1 + = c.Name & ","
End If
Next
For Each r As Row In Tables("上年实际数导入").Rows
sql2 = ""
For Each c As Col In Tables("上年实际数导入").Cols
If c.Name<>"ID" Then
If c.IsDate Then
sql2 + = "'" & r(c.Name) & "'" & ","
ElseIf c.IsString Then
sql2 + = "'" & r(c.Name) & "',"
ElseIf c.IsBoolean Then
If r(c.Name) = True Then
sql2 + = 1 & ","
ElseIf r(c.Name) = False Then
sql2 + = 0 & ","
End If
Else
sql2 + = r(c.Name) & ","
End If
End If
Next
cmd.CommandText + = "S elect " & sql2.Trim(",") & vbcrlf & "Union All" & vbcrlf
Next
cmd.CommandText = "I nSert Into 上年实际数导入 (" & sql1.Trim(",") & ")" & vbcrlf & cmd.CommandText.SubString(0,cmd.CommandText.Length - 11)
cmd.ExecuteNonQuery
DataTables("上年实际数导入").Load
Dim tp As TimeSpan
tp = Date.Now - dt
MessageBox.Show(tp.TotalSeconds)