-
Great Tip
Hi All,
This is a great tip I got from the MSDN CD. I thought it was so good I should
share it with everyone.
Everyone generally uses code like this:
Dim recTemp as New ADODB.RecordSet
recTemp.Open "SELECT * FROM tblABC",cnxMain,yada yada
While not recTemp.EOF
list1.AddItem recTemp!Name
recTemp.MoveNext
Wend
But this can be sped up significantly by getting a reference to the required
field(s) before hand. In the first example VB searches throught the fields
collection once for every record but in the second VB only does this once
no matter how many records.
Dim recTemp as New ADODB.RecordSet
dim fldTemp as ADODB.Field
recTemp.Open "SELECT * FROM tblABC",cnxMain,yada yada
set fldTemp=recTemp.Fields("Name")
While not recTemp.EOF
list1.AddItem fldTemp.Value
recTemp.MoveNext
Wend
I tested this and got 3.2 secs the first way and 1.9 the second way.
Michael Culley
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
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks