Home - Forums-.NET - FlyGrid.Net (Windows Forms) - Problem with DataAdapter.Update

FlyGrid.Net (Windows Forms)

.NET Datagrid - Fast, highly customizable, industry standards .NET data grid control for WinForms

This forum related to following products: FlyGrid.Net

Problem with DataAdapter.Update
Link Posted: 02-Feb-2006 11:26
Hello,
I have created a data grid based on the sample.

Filling of the grid works fine.

But when I use the DataAdapter.Update method I got an exception on the first INT32 field.

It says that the object of the type System.Int32 cannot converted into System.String

I do :

vistaDBUpdateCommand1.Parameters.Add("@F_MEDIUM", VistaDBType.Int32, "F_MEDIUM");
vistaDBDataAdapter1.Update(vistaDBDataSet1, "T_FILME");

In the Grid the field is shown as Number !

Filling the row:
case TypeCode.UInt32:
                                NumberColumn numcol = new NumberColumn(dc.Caption, dc.ColumnName);
                                numcol.NumberType = Type.GetTypeCode(dc.DataType);
                                numcol.TextAlign = ContentAlignment.MiddleRight;
                                if (tc == TypeCode.Decimal)
                                    numcol.FormatString = "C";//currency
                                else if (tc == TypeCode.Single)
                                    numcol.FormatString = "P";//percent
                                else
                                    numcol.EditorStyle = EditorStyle.Spin;

                                col = numcol;
                                break;


What do I wrong ?
Link Posted: 02-Feb-2006 20:36
Hello,
do you have a complete sample using the DataAdapter und the Update / Update.Parameter to update data from the grid ?

The provided samples are good but shows much more and I really want to start with load and save into a database and do the rest step by step ;-)
Thanks and regards
Uwe
Link Posted: 02-Feb-2006 22:45
Probably you've incorrectly initialized DataColumn in the DataTable/Dataview, please make sute that DataColumn associated with this field has correct .DataType
Link Posted: 02-Feb-2006 22:54
Thanks for the reply.

This happens during the for - loop I took from the sample.

Is there a possibilty to check, which type a grid-column got after everything was loaded into the grid ?

Thanks and regards
Uwe
Link Posted: 02-Feb-2006 23:11
You can override NumberColumn.SetValue to check the type of conversion:
[C#]
public override void SetValue(NodeBase node, object value)
{
  //convert value to the NumberType
  if (numberType != Convert.GetTypeCode(value))
    value = Convert.ChangeType(value, NumberType);
  //set value
  base.SetValue (node, value);
}