Reputation: 1
dear all I have many comb boxes in many forms of my application, and ecah should be filled with items from the database so, I want to make store procedure with a combo box name passed as paremeter and then call it from any form
I don't know how to pass it, as what type ? please help
Upvotes: 0
Views: 303
Reputation: 3205
It sounds as though your approach to this problem isn't optimal.
The notion of a "combo-box" isn't usually something which you want to entangle with your database constructs.
Design your application with the intent of modeling you domain's "concepts" in one application layer as classes. If some of this data is frequently needed, and rarely changed, you may want to implement caching of some of this data. Subsequently you can design your UI and associate comboboxes with required lists and collections exposed by your domain model.
Edit: If you really want to use some inherent aspect of the combobox as a parameter into the database (for obtaining items), then I guess you could consider using the Tag property of the control for this. This strategy allows you to have multiple comboboxes on the same form with the same options (such as multiple Yes/No or Opened/Closed combos) without having to deal with naming/uniqueness conflicts.
GetComboSourceData()
which takes a System.Windows.Forms.ControlCollection
as parameter.GetComboSourceData(this.Controls)
to populate your combos.Upvotes: 1