|
-
Jun 1st, 2008, 08:04 PM
#1
Thread Starter
Junior Member
searching access database
Hello,
I have an access database with 100,000+ records that I need to search through. I only need to work with the records that have a value in the account number field. Right now I have it going down the table and whenever it finds a row with an account number in it, it does the computations. This process only allows a few hundred records to be done every minute. I need to speed this up, but I have no clue how. Any help would really help me out 
Code:
For i = 1000 To x 'x is number of rows in table
Adodc1.RecordSource = "SELECT * FROM tSaleTransactions Where cdeTrans='A" & i & "'"
Adodc1.Refresh
If Adodc1.Recordset.Fields("cdeCustCode") <> Empty Then
'does computations
Last edited by mooe; Jun 1st, 2008 at 08:10 PM.
-
Jun 1st, 2008, 08:14 PM
#2
Re: searching access database
Each SQL call is going to take a long time. Faster would be to ditch the databound controls and go with direct access using ADO. And when I say faster, I mean the entire loop would probably take a few seconds from start to finish.
-
Jun 1st, 2008, 08:20 PM
#3
Thread Starter
Junior Member
Re: searching access database
I will admit I know almost nothing about coding, but isn't ado what I am using in my code example? If you could point me in the direction I would really appreciate it.
Thanks!
-
Jun 1st, 2008, 08:41 PM
#4
Re: searching access database
Well I probably wouldn't use that ADODC because it carries a lot of baggage with it. I'm not saying to avoid it, just avoid it for this operation. For example:
Code:
Dim rsCompute As ADODB.Recordset
Set rsCompute = New ADODB.Recordset
With rsCompute
.Open "SELECT only the fields you need FROM tSaleTransactions", _
Adodc1.Recordset.ActiveConnection, _
adOpenForwardOnly, adLockReadOnly, adCmdText
.MoveFirst
Do Until .EOF
If Not IsNull(!cdeCustCode.Value) Then
'Do computations.
End If
.MoveNext
Loop
.Close
End With
Set rsCompute = Nothing
Notes:
- You might want a WHERE clause in the SQL statement if there are values below A1000 that you want to exclude.
- You might want another LockType if you are updating values as part of your "computations."
- You might need to add .Update before .MoveNext if you change field values as part of your "computations."
- You might not want to use Not IsNull() depending on how your "no value" values are stored. For empty String values you should probably use Len() > 0 as a test instead if you didn't store NULLs.
This might be off a little from what you want, but it should be close.
Last edited by dilettante; Jun 1st, 2008 at 08:48 PM.
-
Jun 1st, 2008, 08:45 PM
#5
Re: searching access database
 Originally Posted by mooe
isn't ado what I am using in my code example?
Well, you aren't using ADO; the databound control is. If you use ADO directly you'll greatly improve your control over what's going on, which will allow you to greatly speed up execution.
ETA: dillettante showed you the basic idea. You can also edit data inside the loop. Post any specific questions you have.
Last edited by Ellis Dee; Jun 1st, 2008 at 08:48 PM.
-
Jun 1st, 2008, 09:14 PM
#6
Thread Starter
Junior Member
Re: searching access database
Edit: Realized my mistake. I'm an idiot.
Last edited by mooe; Jun 1st, 2008 at 09:24 PM.
-
Jun 1st, 2008, 09:30 PM
#7
Re: searching access database
No, you're just not used to doing this stuff all the time.
-
Jun 2nd, 2008, 04:23 AM
#8
Re: searching access database
Thread moved to Database Development forum (the "VB6" forum is meant for questions which don't fit in more specific forums)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|