StrataFrame Forum

a simple combobox

http://forum.strataframe.net/Topic17176.aspx

By Eric Leissler - 6/19/2008

Hi ,

Im a french new user of strataframe, so excuse my language fault.

My problem.

I have a form with to businessobject.

The first is  ActeursBO

 It contain a table "acteurs" with  identifiant    int     identity and primary key

                                                 name        char(30)

                                                 firstname   char(10)

                                                 titre_id     int

The  data are

    IDENTIFIANT                     NAME                     FIRSTNAME                 TITRE_ID

                   1                        LEISSLER                ERIC                             3

                   2                        LEISSLER                COLETTE                        2

                   3                        LEISSLER                SEREINE                        1

THE second businnes object is

TITREBO

It contain  table   "titre" with   identifiant   int  identity   primarykey

                                             abrege            char(10)

                                             libelle             char(30)

and the data is

IDENTIFIANT               ABREGE                  LIBELLE

        1                          Melle                      Mademoiselle

        2                           Mme                      Madame

        3                           M.                          Monsieur

So in my form i have  acteursBO1  and  TitresBO1

in the property of titresbo1 i have  ParentbusinnesObject  = ActeursBo1

So i drop a  strataframe combobox in my form

on property  i go to Businnesobject and i select Acteursbo1

In bindingfields i select titre_id

in the property Plulatiopndatasourcesettings  i select in busines obect type titresbo

in display member i select abrege and in value number i select identifiant

When i execute i have an error  at the line

ctype(component,acteursbo).titre_id = ctupe(value,system.int32)

the error is the conversion of type  dbnull  in type integer is not valid

What can i do ?

what i have not do ?

what i have to do  ?

i don't find in the example à simple exemple with a simple combobox.

Somebody  can  send an  sample example like this problem ?

I will thank you for the time  you pass'd to read this post

Best regard

Eric LEISSLER

By Edhy Rijo - 6/19/2008

Hi Eric and welcome to the forums.

So in my form i have  acteursBO1  and  TitresBO1

in the property of titresbo1 i have  ParentbusinnesObject  = ActeursBo1

So i drop a  strataframe combobox in my form

on property  i go to Businnesobject and i select Acteursbo1

In bindingfields i select titre_id

in the property Plulatiopndatasourcesettings  i select in busines obect type titresbo

in display member i select abrege and in value number i select identifiant

When i execute i have an error  at the line

ctype(component,acteursbo).titre_id = ctupe(value,system.int32)

the error is the conversion of type  dbnull  in type integer is not valid

Here are some things I see in your code:

  • You don't need to have the TitresBO1 in the form, since the combobox class will use an internal BO to show the lookup data and there will be no need to update the ParentBusinessObject since this BO is not needed in the form.
  • In the TitresBO.vb class, modify the code and add a method that will return you all the records for that table and use that method in your ComboBox.PopulationDataSourceSettings property.  Here is an example of what I use in these cases:

#Region " Data Retrieval Methods "

     ''' <summary>

     ''' This method will return all records from the table InsuredCorporation

     ''' </summary>

     ''' <remarks></remarks>

     Public Sub FillAllRecords()

          Using cmd As New SqlCommand()

               cmd.CommandText = String.Format("Select * From {0} ORDER BY CorporationName", Me.TableName)

               Me.FillDataTable(cmd)

          End Using

     End Sub

#End Region

  • Recompile your TitresBO.vb class so you can see the new method FillAllRecords in the designer Properties windows.
  • Now modify your ComboBox.PopulationDataSourceSettings property to use the new method TitresBO.FillAllRecords().

Here is a picture of the ComboBox properties:

Now, Save, Rebuild and Test....

Good luck!

By Eric Leissler - 6/19/2008

Hi Edhy

Its really great  !

Thanks you very much

I made this changement and its ok  now .

I can continue my learning of strataframe.

Great thanks

Best regards

Eric

By Edhy Rijo - 6/19/2008

Hi Eric,

I am glad it worked for you. Smile

Also the forum's search feature is pretty good and you can do searches to find specific topics which may give you an answer quickly.  Since I am also learning SF, I use the forums all the time and they are a great, great resouces.

By Eric Leissler - 6/19/2008

Thank you tremeThank you tremendously anyway, because it allows me to advancendously anyway, because it allows me to advance

best regards

Eric