Filling a combo box from a module

Joined
Oct 20, 2006
Messages
21
Programming Experience
Beginner
I have been playing around with Access connections using ado.net. I have successfully made a connection and passed info from the database to a form. Recently I started using modules which I have the form call. I am able to pass string variables back but I ‘m a little confused what to pass back for a combo box or list box. I know how to fill them if I make the connection in the form but not the module. For example with a text box I declare it as a string in the module and that works fine, but what do I declare a combo box as? Also how do I pass the data back to the form to fill multiple entries in the combo box?
 
in .NET 2.0 - the version that you are using, data access is indeed done in the way you proscribe here. If you follow the link in my signature Data Walkthroughs 2.0 it will guide you in a few basic (and more advanced) data access techniques. Following that guidance will get you to a point where you have a DataSet with all the relevant data access code held within (like your module idea - put all the db code in one logical place)

Examining this code, you will realise that the tableadapters in the dataset have one or two methods: GetData, and Fill
If you gave any parameters to the SQL, then it will have asked you to name them as GetDataByXXX and/or FillByXXX.

GetData is a method that returns a datatable, Fill is a method that fills a datatable.

Typically thus, the modus operandi is for your form to make a datatable that will be the datasource for the combo, and then call on the tableadapter to fill it..

If you choose to avoid the DataSet designer and write your own access code (which would be a little akin to choosing to ignore the form designer and lay your forms out manually) you can adopt the same notion:

Provide a method that takes a datatable, and uses an internal adapter to fill it. The form will make the table, pass it to the method, and when the method exits, the datatable will be filled
 
Back
Top