StrataFrame Forum
Home      Members   Calendar   Who's On
Welcome Guest ( Login | Register )
      


123»»»

Conversion from type 'DBNull' to type...Expand / Collapse
Author
Message
Posted 03/07/2006 10:13:47 PM


StrataFrame Novice

StrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame 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?

  Post Attachments 
combobox_properties.gif (65 views, 77.33 KB)
dbnull_error.gif (62 views, 62.65 KB)
sql_data.gif (57 views, 63.20 KB)
textbox_properties.gif (50 views, 76.22 KB)

Post #596
Posted 03/07/2006 10:16:08 PM


StrataFrame Novice

StrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame Novice

Group: StrataFrame Users
Last Login: 10/17/2008 1:02:11 PM
Posts: 87, Visits: 779
I forgot to say thanks in advance..
Post #597
Posted 03/08/2006 8:56:35 AM


StrataFrame Developer

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
Post #598
Posted 03/10/2006 5:25:32 PM


StrataFrame Novice

StrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame 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 frmCadClubes

Private Sub ClubesBO1_ParentFormLoading() Handles ClubesBO1.ParentFormLoading

Me.ClubesBO1.FillTop100()

End Sub

Private Sub ComboBox1_ParentFormLoading() Handles ComboBox1.ParentFormLoading

Me.ClubesBO1.FillTop100()

End Sub

End Class

Im not sure, if Im doing right, because Im getting the same error... please help .. thanks

Post #611
Posted 03/10/2006 5:42:27 PM


StrataFrame Developer

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.

Post #613
Posted 03/13/2006 1:15:56 AM


StrataFrame Novice

StrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame Novice

Group: StrataFrame Users
Last Login: 10/17/2008 1:02:11 PM
Posts: 87, Visits: 779
Awesome ! Thanks, Trent !
Post #624
Posted 03/13/2006 12:44:33 PM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: Yesterday @ 4:50:35 PM
Posts: 4,796, Visits: 4,766
Glad to help
Post #628
Posted 03/14/2006 8:58:05 PM


StrataFrame Novice

StrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame 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

Post #640