| | | 
StrataFrame Novice
       
Group: StrataFrame Users Last Login: 10/17/2008 1:02:11 PM Posts: 87, Visits: 779 |
| Hello.. this is what I am doing now... Im trying to pupulate the combo box, but i'm gettin this error "Conversion from type 'DBNull' to type 'String' is not valid.". The funny thing is that I have a a text box that loads from the same BO and loads the same field, and it's working..
PS - I dont have any null info on the "nome_clube" field on the table.Any Clues.. anyone?
|
| | | | 
StrataFrame Novice
       
Group: StrataFrame Users Last Login: 10/17/2008 1:02:11 PM Posts: 87, Visits: 779 |
| I forgot to say thanks in advance.. |
| | | | 
StrataFrame Developer

Group: StrataFrame Developers Last Login: Yesterday @ 1:09:23 PM Posts: 2,686, Visits: 1,888 |
| Hello Ricardo,
Your problem is not because you have a NULL field in your data, the problem is that there is no data in the combo box to copy back into the field (it's throwing the error on SetValue(), not GetValue()). So, I assume that since you're not populating the combobox through StrataFrame you must be populating it manually. In this case, it's probably being bound before getting populated.
If you're populating in the Load event of the form, then move your code that populates the combobox to the ParentFormLoading event of the combobox to ensure that it gets populated before binding to the business object.
www.bungie.net |
| | | | 
StrataFrame Novice
       
Group: StrataFrame Users Last Login: 10/17/2008 1:02:11 PM Posts: 87, Visits: 779 |
| | Hello Ben, please is this right? Public Class frmCadClubesPrivate Sub ClubesBO1_ParentFormLoading() Handles ClubesBO1.ParentFormLoadingMe.ClubesBO1.FillTop100()End SubPrivate Sub ComboBox1_ParentFormLoading() Handles ComboBox1.ParentFormLoadingMe.ClubesBO1.FillTop100()End SubEnd ClassIm not sure, if Im doing right, because Im getting the same error... please help .. thanks |
| | | | 
StrataFrame Developer

Group: StrataFrame Developers Last Login: Yesterday @ 4:50:35 PM Posts: 4,796, Visits: 4,766 |
| | Ricardo, Since you are trying to popualte a combo from a business object, you should use the PopulateionDataSourceSettinngs on the combo box itself. Also you will need to change the population method from manual to BusinessObject on the combo box also. The code sample you showed above is actually not going to work for two reasons. First, you are populating the business object twice. Once in the ParentFormLoading of the combo box and again in the load of the business object itself. Secondly, the reason you are still getting the error is because the DataSource, DisplayMember, and ValueMember of the combo box were never set which tells the combo how to populate and interact with the bound data. So you need to do one of two things: Manual Population 1. Remove the Me.ClubesBO1.FillTop100() from the ParentFormLoading event of the business object itself. Leave the other in the combo boxes ParentFormLoading. 2. Make the combo box ParentFormLoading event look like this: Private Sub ComboBox1_ParentFormLoading() Handles ComboBox1.ParentFormLoading Me.ClubesBO1.FillTop100()
'-- Set the display member Me.ComboBox1.DisplayMember = "[MyDisplayFieldName]" Me.ComboBox1.ValueMember = "[MyValueMemberField - Usually a Primary Key Field]" Me.ComboBox1.DataSource = Me.ClubesBO1.CurrentDataTable End Sub End Class
Replace the display and value member fields with the names of the fields you wish to use.
Better Solution - PopulationDataSourceSettings 1. Remove all of calls to ClubesBO1.FillTop100 from all methods. 2. Through the form designer, navigate to the combo box. 3. In the property sheet, navigate to the PopulationDataSourceSettings 4. Click the "..." button to the right of the value 5. When the editor appears, set the Business Object Type to "ClubesBO" 6. Set the Method to Execute to "FillTop100()" 7. Add the fields that you wish to have displayed in the combo box at the bottom left of the editor 8. To tell the combo box how to use those selected display fields, set the Display Member Format String. For example, if you only added a single display member field, the format string will look like this: {0} 9. Pick the value Member field. This is the fields that will be bound to the data. 10. Click OK. 11. Set the PopulationType property on the combo box to Business Object. 12. Save your changes and run the form. This should get you going. Let me know if you have any questions. |
| | | | 
StrataFrame Novice
       
Group: StrataFrame Users Last Login: 10/17/2008 1:02:11 PM Posts: 87, Visits: 779 |
| | Awesome ! Thanks, Trent ! |
| | | | 
StrataFrame Developer

Group: StrataFrame Developers Last Login: Yesterday @ 4:50:35 PM Posts: 4,796, Visits: 4,766 |
| Glad to help |
| | | | 
StrataFrame Novice
       
Group: StrataFrame Users Last Login: 10/17/2008 1:02:11 PM Posts: 87, Visits: 779 |
| | Hi, Trent... me again.. now I can load comboboxes on all forms.. that makes me very happy... but can u please teach me how to save the data from a diferent table to the first? Example: I have a form 1 to insert data from Clubs (soccer), then i load all the textboxes, from the table called (tb_clube), to insert, edit.. and been filled by a BO called "clubeBO", all okidoki like the example you guys made on the tutorial. Then I inserted a new BO called "paisBO" (means country), and made the same fill method. If i put a combobox to load like u teach me, it brings all the countries... But the thing is that I want to insert on the clubs form this countries comboBox, to load the data from the coutries table and insert the value field (a primary key called pais_id_cod) on the country field on the clubs table.. and somehow, when i navigate the records, see the country that belongs to that team... instead of the value.... like 1, 2, 3.... Am I been anoying? , not sure if it's even possible... but i guess it is... not sure how with strataframe... either... If u got time, and nothing better to it... please drop a few lines.. (of code too)  Best Regards... Ricardo |
| | | |
|