Error on fetching DOUBLE from INTERBASE

Posts   
 
    
wexa
User
Posts: 38
Joined: 27-Jul-2007
# Posted on: 18-Oct-2007 07:38:02   

I am using v. 2.5 using adapter and Interbase. I can save on database, fetch the collection but when I try to fill a grid or handle an individual entity, I get a

System.Reflection.TargetInvocationException

{"El descriptor de acceso de la propiedad 'TotalAgregar' inició la excepción 'La conversión especificada no es válida.' en el objeto 'Apm.EntityClasses.MpsComposicionLoteEntity'"}

This is the StackTrace:

    StackTrace  "   en System.ComponentModel.ReflectPropertyDescriptor.GetValue(Object component)\r\n   en System.Windows.Forms.DataGridView.DataGridViewDataConnection.GetValue(Int32 boundColumnIndex, Int32 columnIndex, Int32 rowIndex)"    string
  • [System.Reflection.TargetInvocationException] {"El descriptor de acceso de la propiedad 'TotalAgregar' inició la excepción 'La conversión especificada no es válida.' en el objeto 'Apm.EntityClasses.MpsComposicionLoteEntity'"} System.Reflection.TargetInvocationException

I generated the code and have not moved it, the database has all the values as double and in the entity are defined as double too.

I am using Interbase 7.1 do you think it may be drivers?

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 18-Oct-2007 11:05:32   

just to make sure, would you please translate the exception? Also post a simple code snippet which lead to that exception.

wexa
User
Posts: 38
Joined: 27-Jul-2007
# Posted on: 18-Oct-2007 16:08:46   

I have a datagridView on windows forms, I fetch the EntityCollection, the columns have been made automatically in the datagrid when selecting the DataSource.

I added in designer an EntityCollection to a Binding Source then the BindingSource to the grid.

If I delete the 3 columns from the grid that are double in the database I get no errors.



 public void LoadData(int numLot)
        {
            DataAccessAdapter adapter = new DataAccessAdapter();
            IRelationPredicateBucket bucket = new RelationPredicateBucket();
            _loteAModificarCollection.Clear();
           bucket.PredicateExpression.Add(MpsCompositionFields.Lote == numLot);
            adapter.FetchEntityCollection(_loteAModificarCollection, bucket);
            adapter.CloseConnection();  
        }
]

I also get the error when fetching an entity, when loading data from those fields. I have the error on the GET at the generated code in this part of any of the 3 DOUBLE columns:


/// <summary> The TotalAgregado property of the Entity MpsCompositionLote<br/><br/>
        /// </summary>
        /// <remarks>Mapped on  table field: "MPS_COMPOSITION_LOTE"."TOTAL_AGREGADO"<br/>
        /// Table field type characteristics (type, precision, scale, length): Double, 10, 5, 8<br/>
        /// Table field behavior characteristics (is nullable, is PK, is identity): true, false, false</remarks>
        public virtual Nullable<System.Double> TotalAgregado
        {
            get { return (Nullable<System.Double>)GetValue((int)MpsCompositionLoteFieldIndex.TotalAgregado, false); }
            set { SetValue((int)MpsCompositionLoteFieldIndex.TotalAgregado, value); }
        }

I debugged using this too:

            DataAccessAdapter adapter = new DataAccessAdapter();
            MpsComposicionLoteEntity ent = new MpsComposicionLoteEntity(1);
            adapter.FetchEntity(ent);
            MessageBox.Show(ent.TotalAgregado.ToString());

after fetching the entity and wathcing the values, on the columns that are double I get this:

'ent.Consumo' threw an exception of type 'System.InvalidCastException'

wexa
User
Posts: 38
Joined: 27-Jul-2007
# Posted on: 18-Oct-2007 16:10:08   

I have recreated the table, the columns where internally as Double, but getting as numeric, I did recreated them and now LLBL took them as double, I think it was something from Interbase.

Regards

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 18-Oct-2007 16:22:12   

Glad you have worked it out.