Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

other ways to fill combobox

Status
Not open for further replies.

sfenx

Programmer
Feb 23, 2001
81
BE
What's the easiest (and fastest) way to fill a combobox with data from a database ? I always do this with a for-loop, additem and movenext commands. Is it better not to use a data-object so that the connection doesn't stay open from startup ? Is there a component (ado) that combines a dropdown list with a database ? :cool:
 
Open connection at startup?
Why don't you just open it just before using it, then close it?

-Mats Hulten
 
Is there a way to open a data-object when using a control, so that the connection isn't open at startup ?
What's the easiest (and fastest) way to fill a combobox with data from a database ?

Sfenx :cool:
 
On load_form()

Data1.DataBasename = ""

end if

On command_click()

Data1.DataBasename = "C:\Whatever.database"
Data1.refresh

end if

set your combobox datasource to data1
set your combobox datafield to the data1 field you want it to show
 
je kan het toch sluiten na het vullen van de combobox !

Rs.Close

he is a Duth guy like me (or Belgian)

You can close the recordset after put data in the combobox

Rs.Close Eric De Decker
vbg.be@vbgroup.nl

License And Copy Protection AxtiveX.

Download Demo version on my Site:
 
Thanks guys !
I'm rather new to VB so...
And Eric : yes, I'm Belgian.
 
If you want 'fast', then stay away from data bound controls altogether and spend the time to code the database access yourself. Define a database and a recordset, open the database, then the snapshot-type recordset, then loop thru the recordset, adding items, then finally close the recordset and database.
That solution ought to be the fastest and least resource-heavy.

/Cy
 
To add to CyBorg:
If you use ADO, open the rs with a User side cursor(rsMyData.CursorLocation = adUseClient) and you dis-connect from the DB immediately after getting the rs(before you do any data manipulation. You'd still need to loop thru the rs however
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top