JackCrackers
Registered User.
- Local time
- Today, 15:46
- Joined
- Apr 17, 2009
- Messages
- 13
Hello,
I am writing using VBA inside of autocad or VB 6.0. (So I may be in the wrong place). From either environment I import data to an Access .mdb file. The data is in text files separated by either commas or spaces (fixed width columns). My problem is that these files are very large and it takes to long to load them into the Access file. These files contain numeric data (co-ordinates) and are stored as long integers in Access. I am using Access 2003 type .mdb files. These files can be several millions of lines long.
Here is some typical code that works, but is too slow.
Set dbsObj = DBEngine.Workspaces(0).OpenDatabase("d:\temp3.mdb")
Set rstObj = dbsObj.OpenRecordset("tblcoorsJHL2", dbOpenTable)
'separated by commas
Open "c:\temp\data.txt" For Input As #1
'Start reading text file to temp.mdb
Do
Input #1, ya$
Input #1, xa$
Input #1, za$
yt# = Val(ya$)
xt# = Val(xa$)
If OptionButtonAddMinus Then
zt# = Val(za$) * -1
Else
zt# = Val(za$)
End If
rstObj1.AddNew
rstObj1!yxdata = CLng(yt# * 100)
rstObj1!Xxdata = CLng(xt# * 100)
rstObj1!Zxdata = CLng(zt# * 100)
rstObj1.Update
Loop Until EOF(1)
Close 1
Is there anyway to make this process go fast?
Thanks for reading my post
John
I am writing using VBA inside of autocad or VB 6.0. (So I may be in the wrong place). From either environment I import data to an Access .mdb file. The data is in text files separated by either commas or spaces (fixed width columns). My problem is that these files are very large and it takes to long to load them into the Access file. These files contain numeric data (co-ordinates) and are stored as long integers in Access. I am using Access 2003 type .mdb files. These files can be several millions of lines long.
Here is some typical code that works, but is too slow.
Set dbsObj = DBEngine.Workspaces(0).OpenDatabase("d:\temp3.mdb")
Set rstObj = dbsObj.OpenRecordset("tblcoorsJHL2", dbOpenTable)
'separated by commas
Open "c:\temp\data.txt" For Input As #1
'Start reading text file to temp.mdb
Do
Input #1, ya$
Input #1, xa$
Input #1, za$
yt# = Val(ya$)
xt# = Val(xa$)
If OptionButtonAddMinus Then
zt# = Val(za$) * -1
Else
zt# = Val(za$)
End If
rstObj1.AddNew
rstObj1!yxdata = CLng(yt# * 100)
rstObj1!Xxdata = CLng(xt# * 100)
rstObj1!Zxdata = CLng(zt# * 100)
rstObj1.Update
Loop Until EOF(1)
Close 1
Is there anyway to make this process go fast?
Thanks for reading my post
John