Conversion from type 'DBNull' to type 'String' is not valid.


Author
Message
Ricardo Quartier
Ricardo Quartier
StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)
Group: Forum Members
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?

Attachments
combobox_properties.gif (264 views, 77.00 KB)
dbnull_error.gif (270 views, 62.00 KB)
sql_data.gif (241 views, 63.00 KB)
textbox_properties.gif (255 views, 76.00 KB)
Replies
Ricardo Quartier
Ricardo Quartier
StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)StrataFrame User (145 reputation)
Group: Forum Members
Posts: 87, Visits: 779
Yo, last "question" and a diferent help BigGrin

Now I have those 3 combos, like i said before, the thing is that they are not really "very" dependent. So this way I can chooseto set a club on any country (this is allright) but then when i drop down the states, it shows the states of all countries, anyway, this one is agressive, when i drop down the cities, it show thousands of cities from all around the world. w00t

My database is kind simple (4 tables right now)

Clubs
-------
clubId
countryId
stateId
cityId

Contries
--------
countryId
description

State
-------
stateId
description

Cities
-------
cityId
description

Is there any way of strataframe to handle this, "make then dependent"? I use to do this on aspx pages.. using a comand on a query, that concatenate the sql and the value of the parent combo, like:

"select * from states where country = ' & cboCountries.selectedvalue = 25 & '"

Something like that... then i put the code on the event change of the combo and on the form load to bring right the first record.

Any great clues? a "how to" will be great, i won't lie (if that does not take so much time from u).

Best Regards,

Ricardo

Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
Right now you are populating each combo box using all rows in the respective table.  This will obviously not work very well for tables with a lot of records.  You only need to show the cities that belong to state when populating the cities combo, and then you need to only load the available states for the selected country.

I assume that your database knows these relationships.  I am going to talk about the city combo, but the same will apply to the states.  In your table, your city data structure should know the state to which it belongs.  So you would need to create a Fill method on the BO that looks something like this:

Public Sub FillCityByState(Byval StatePrimaryKey As Integer)
     Me.FillDataTable("SELECT * FROM cities WHERE city_state = " & StatePrimaryKey.ToString())
End Sub

Next, you will want to change the PopulationDataSourceSettings of the city combo to use the above method.  The one thing that you need to is specify the parameter StatePrimaryKey when the combo loads.  To do this, capture the ListPopulating event on the city combo box.  Inside that event, place code similar to this:

e.Parameters(0).Value = MyStates.State_PrimaryKey

Now you need to tell the city combo to reload when the state changes.  So in the SelectedValueChanged or the SelectedIndexChanged event of the State combo box, place the following code:

MyCityCombo.Requery()

This will force the cities to repopulate based on the new state selection.

Once last thing you can do to make sure that the object populate in the correct order since they rely on one another, is set the InitializationPriority.  This will ensure that order they are loaded when instantiating the form will happen in the proper order.  Place a value like this on each combo:

Country Combo Initialization Priority: 25
State Combo Initialization Priority: 26
City Combo Initialization Priority: 27

Let me know if you have any questions.

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Threaded View
Threaded View
Ricardo Quartier - 19 Years Ago
Ricardo Quartier - 19 Years Ago
StrataFrame Team - 19 Years Ago
Ricardo Quartier - 19 Years Ago
Trent L. Taylor - 19 Years Ago
Ricardo Quartier - 19 Years Ago
             Glad to help ;)
Trent L. Taylor - 19 Years Ago
Ricardo Quartier - 19 Years Ago
Trent L. Taylor - 19 Years Ago
Ricardo Quartier - 19 Years Ago
Trent L. Taylor - 19 Years Ago
Ricardo Quartier - 19 Years Ago
             Glad to hear it ;)
Trent L. Taylor - 19 Years Ago
Ricardo Quartier - 19 Years Ago
Trent L. Taylor - 19 Years Ago
Ricardo Quartier - 19 Years Ago
Robert Linton - 19 Years Ago
Trent L. Taylor - 19 Years Ago
Ricardo Quartier - 19 Years Ago
Trent L. Taylor - 19 Years Ago
Ricardo Quartier - 19 Years Ago
Trent L. Taylor - 19 Years Ago
Ricardo Quartier - 19 Years Ago
             Got it...thanks.
Trent L. Taylor - 19 Years Ago
Ricardo Quartier - 19 Years Ago
Trent L. Taylor - 19 Years Ago
Edhy Rijo - 18 Years Ago
StrataFrame Team - 18 Years Ago

Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search