我的数据库文件变大了40倍!请各位大侠帮忙看看!
VB数据库程序:
Private Sub Command1_Click()
Dim T As Long
Dim H As Long
H = 60000
Dim cnn1 As ADODB.Connection
Set cnn1 = New ADODB.Connection
cnn1.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" _
& App.Path & IIf(Right(App.Path, 1) = "\", "", "\") & "parameter.mdb"Dim a As ADODB.Recordset
Set a = New ADODB.Recordset
a.Open "select * from Record1", cnn1, adOpenKeyset, adLockOptimistic
For T = 0 To 10000
a.AddNew
a.Fields("RecordNumber").Value = T
a.Fields("Frequency_Out").Value = H
a.Fields("Current_Out").Value = H
a.Fields("Voltage_Out").Value = H
a.Fields("time").Value = Now
a.Update
Next T
a.Close
添加了10000条记录,数据库文件parameter.mdb才1M,然后1秒更新一条记录:
Private Sub Timer1_Timer()
Static sss As Integer
Dim ppp As Long
ppp = 77777
Dim cnn1 As ADODB.Connection
Set cnn1 = New ADODB.Connection
cnn1.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" _
& App.Path & IIf(Right(App.Path, 1) = "\", "", "\") & "parameter.mdb"
Dim a As ADODB.Recordset
Set a = New ADODB.Recordset
a.Open "select * from Record1", cnn1, adOpenKeyset, adLockOptimistic
a.Move (sss)
a.Fields("Frequency_Out").Value = ppp
a.Fields("Current_Out").Value = ppp
a.Fields("Voltage_Out").Value = ppp
a.Fields("time").Value = Now
a.Update
a.Close
sss = sss + 1
If sss = 10000 Then
sss = 0
End If
End Sub
结果数据库文件parameter.mdb变成40M了,增大了40倍??
VB数据库程序:
Private Sub Command1_Click()
Dim T As Long
Dim H As Long
H = 60000
Dim cnn1 As ADODB.Connection
Set cnn1 = New ADODB.Connection
cnn1.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" _
& App.Path & IIf(Right(App.Path, 1) = "\", "", "\") & "parameter.mdb"Dim a As ADODB.Recordset
Set a = New ADODB.Recordset
a.Open "select * from Record1", cnn1, adOpenKeyset, adLockOptimistic
For T = 0 To 10000
a.AddNew
a.Fields("RecordNumber").Value = T
a.Fields("Frequency_Out").Value = H
a.Fields("Current_Out").Value = H
a.Fields("Voltage_Out").Value = H
a.Fields("time").Value = Now
a.Update
Next T
a.Close
添加了10000条记录,数据库文件parameter.mdb才1M,然后1秒更新一条记录:
Private Sub Timer1_Timer()
Static sss As Integer
Dim ppp As Long
ppp = 77777
Dim cnn1 As ADODB.Connection
Set cnn1 = New ADODB.Connection
cnn1.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" _
& App.Path & IIf(Right(App.Path, 1) = "\", "", "\") & "parameter.mdb"
Dim a As ADODB.Recordset
Set a = New ADODB.Recordset
a.Open "select * from Record1", cnn1, adOpenKeyset, adLockOptimistic
a.Move (sss)
a.Fields("Frequency_Out").Value = ppp
a.Fields("Current_Out").Value = ppp
a.Fields("Voltage_Out").Value = ppp
a.Fields("time").Value = Now
a.Update
a.Close
sss = sss + 1
If sss = 10000 Then
sss = 0
End If
End Sub
结果数据库文件parameter.mdb变成40M了,增大了40倍??
Filename1 = MyPath & "HGas2006.mdb"
Filename2 = MyPath & "datatemp.mdb"
paswd = ";pwd=12345678"
If UCase(Dir(Filename2)) = UCase("datatemp.mdb") Then Kill Filename2
DBEngine.CompactDatabase Filename1, Filename2, , , paswd
Kill Filename1
Name Filename2 As Filename1