StrataFrame Forum

ERROR - BrowseDialog - Search Field Criteria

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

By Rogerio Mauri - 5/17/2008

BrowseDialog Error Crying

When the search criterion is configured in a field byte occurs an error of conversion of types.

It sees the archive attached and the image below.

By Ivan George Borges - 5/17/2008

Hi Rogerio.

As it looks like, you have defined your pk as Tinyint, which will be converted into Byte, and don't forget, this will limit the number of records on this table.

Not sure if this is the cause to the error you are getting. Would you like to test defining the field as Integer? Just to test. I'm sure the guys will give you a more in depth solution on this.

By Rogerio Mauri - 5/17/2008

Olá Ivan...

A escolha de 'tinyint' para esse campo chave primária é porque ele pertence a uma tabela que, na verdade, é um dicionário que nunca ultrapassará o limite de 255 registros.

Sempre que defino um campo numérico procuro ajustá-lo ao tipo mais econômico sem prejuízo do seu 'tempo de vida'. Por exemplo, para IDs(PKs) de tabelas de cadastro e movimento, utilizo o 'int'. Agora, para campos marcadores se situação/status apenas (referenciados em outras tabelas ou em enumeradores) escolho o menor tamanho possível: smallint ou tinyint. Com isso o banco de dados irá consumir menos espaço.

Um exemplo: Codificamos em uma tabela um campo numérico para diferenciar um status com três possibilidades exclusivas: (1-Pendente/2-Bloqueado/3-Finalizado). Então, por que utilizar um 'int' que irá consumir 4 bytes se posso perfeitamente acomodar a demanda em um tinyint que consome apenas 1 byte?

Notei que os desenvolvedores da MicroFour, nos exemplos - mesmo com enumeradores, utiliza o 'int'. Acredito que essa 'preferência' para o 'int' tenha deixado escapar algum 'bug' no código do 'Search Field Criteria' do 'BrowseDialog'.

By Rogerio Mauri - 5/17/2008

I found the cause of the error.

'MicroFour.Strataframe.Data.ObjectConverter.ConvertValue(ByVal InputValue As Object, ByVal OutputType As Type)'.

The explicit conversion of ' string ' for ' byte ' is not codified.

TongueTongueTongue

By Rogerio Mauri - 5/17/2008

Ops...

Rogerio Mauri (05/17/2008)
The explicit conversion of ' string ' for ' byte ' is not codified.

'string' to 'byte'

By Trent L. Taylor - 5/19/2008

I will put this on the list to look at versus making a wholesale change...I think that there are going to be some downstream consequences by changing just this one thing...I think that the browse will need to take this into account as well.
By Michel Levy - 3/11/2014

Hi Trent,

I'm facing the same error today...

InvalidOperationException
  The input value could not be converted to the output type.
ArgumentException
  A value of type 'System.String' cannot be converted to type 'System.Byte'

Source     : MicroFour StrataFrame Base

Stack Trace:

   à MicroFour.StrataFrame.Data.ObjectConverter.ConvertValue(Object InputValue, Type InputType, Type OutputType, String FormatString)

   à MicroFour.StrataFrame.Data.ObjectConverter.ConvertValue(Object InputValue, Type OutputType)
   à MicroFour.StrataFrame.UI.Windows.Forms.ListControl.PopulateComboFromBusinessObject(IListControl lstControl, Object[] Parameters)
   à MicroFour.StrataFrame.UI.Windows.Forms.ListControl.PopulateCombo(Control lstControl, Object[] Parameters)
   à MicroFour.StrataFrame.UI.Windows.Forms.ComboBox.PopulateCombo(Object[] Parameters)
   à MicroFour.StrataFrame.UI.Windows.Forms.ComboBox.Requery()
   à MicroFour.StrataFrame.UI.Windows.Forms.BrowseDialogwindow.CreateBOCombo(SearchFieldItem Item)
   à MicroFour.StrataFrame.UI.Windows.Forms.BrowseDialogwindow.CreateAllSearchFieldControls()
   à MicroFour.StrataFrame.UI.Windows.Forms.BrowseDialogwindow.AddSearchFields()
   à MicroFour.StrataFrame.UI.Windows.Forms.BrowseDialogwindow..ctor(BrowseDialog browse, Boolean PopulateOnShow)
   à MicroFour.StrataFrame.UI.Windows.Forms.BrowseDialog.ShowDialog(Boolean PopulateOnShow, IWin32Window ResultsWindowOwner)
   à MicroFour.StrataFrame.UI.Windows.Forms.BrowseDialog.ShowDialog(Boolean PopulateOnShow)
   à MicroFour.StrataFrame.UI.Windows.Forms.BrowseDialog.ShowDialog()
   à MicroFour.StrataFrame.UI.Windows.Forms.MaintenanceFormToolStrip.cmdBrowse_Click(Object sender, EventArgs e)
   à System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
   à System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
   à System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
   à System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
   à System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   à System.Windows.Forms.Control.WndProc(Message& m)
   à System.Windows.Forms.ToolStrip.WndProc(Message& m)
   à System.Windows.Forms.Control.ControlNativewindow.WndProc(Message& m)
   à System.Windows.Forms.Nativewindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


What sould be the best workaround?

I can modifiy my datatype to SmallInt because the data are not in production, but if I could do something on my VB code, I prefer.

Thanks

(SF version 1.7.6)