为什么我在VB中使用ADO打开.dbf数据库并一条一条追加到SQL Server数据库(服务器上),544条记录竟用了8分钟?

zengjun1980 2001-05-27 05:12:00
...全文
52 点赞 收藏 6
写回复
6 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
zengjun1980 2001-05-27
问题就在这里呀,执行没问题就是速度慢得让人受不了呀,唉VB
回复
zsuny 2001-05-27
你只要把
strconnect = "User ID=Admin;Password=;Data Source=" & g_dbname & _
";Provider=Microsoft.Jet.OLEDB.3.51"
中的Provider的值改成Microsoft Visual Foxpro ,再把相应的名称换成.dbf就行了呀
回复
zengjun1980 2001-05-27
请问wyo(欧亚大陆桥):我是使用本地的DBF数据库并不是MDB数据库,如果是MDB的我想是不会慢到哪里么的。可现在我用的必须是DBF,请教了,解决问题我一定给分就算你并不是为分而来。
回复
wyo 2001-05-27
怎么用VB脚本语言打开数据库,我还是第一次看到
Set FileWorker = CreateObject("Scripting.FileSystemObject")
FileWorker.copyfile "\\ksntser\ksnt_01\kum\worker.dbf", "c:\worker.dbf"

试试下面语句
Dim xiaoshou1 As New ADODB.Recordset '定义ADO
DIM XIAOSHOU2 AS NEW ADODB.RECORDSET
g_dbname="d:\cmis\sale.mdb"
strconnect = "User ID=Admin;Password=;Data Source=" & g_dbname & _
";Provider=Microsoft.Jet.OLEDB.3.51"

'ado方式打开数据库
sql$ = "SELECT * from 临时销售表 "
xiaoshou1.Open sql$, strconnect, adOpenKeyset, adLockOptimistic, adCmdText

sql2$="SELECT * from 销售表"
xiaoshou1.Open sql$, strconnect, adOpenKeyset, adLockOptimistic, adCmdText

Do Until xiaoshou1.eof
xiaoshou2.AddNew

xiaoshou2!发票ID = xiaoshou1!发票ID
xiaoshou1.MoveNext
Loop
xiaoshou1.close
xiaoshou2.close
回复
Dim Cntemp As New ADODB.Connection
Dim Retemp As New ADODB.Recordset
Dim Re As New ADODB.Recordset
Dim FileWorker
Dim i As Long
Dim lngRecount As Long
Set FileWorker = CreateObject("Scripting.FileSystemObject")
FileWorker.copyfile "\\ksntser\ksnt_01\kum\worker.dbf", "c:\worker.dbf"
Cntemp.Open "Provider=MSDASQL.1;Persist Security Info=False;Data Source=dBASE Files;Initial Catalog=c:\"
Retemp.Open "SELECT NAME,BR_CODE,DEPT From worker WHERE (((worker.DEPT) Like '%车衣%' Or (worker.DEPT) Like '%质检%') AND ((worker.RESON) Is Null))", Cntemp, adOpenStatic, adLockReadOnly, adCmdText
cnMain.Execute "delete from workerinfo" ‘cnmain是我的SQL服务器的连接变量
Re.Open "workerinfo", cnMain, adOpenStatic, adLockOptimistic, adCmdTable
Retemp.MoveLast
lngRecount = Retemp.RecordCount
MsgBox lngRecount
Retemp.MoveFirst
For i = 1 To lngRecount
Re.AddNew
Re("name") = Trim(Retemp("name"))
Re("br_code") = Trim(Retemp("br_code"))
Re("dept") = Trim(Retemp("dept"))
Re.Update
Retemp.MoveNext
Next i
回复
LK007 2001-05-27
将你的源码写出来看看,那不可能!
回复
相关推荐
发帖

1188

社区成员

VB 数据库(包含打印,安装,报表)
申请成为版主
帖子事件
创建了帖子
2001-05-27 05:12
社区公告
暂无公告