| | | StrataFrame User
       
Group: StrataFrame Users Last Login: Yesterday @ 3:00:39 PM Posts: 244, Visits: 816 |
| | Time to get some help on this. I have a comboboxedit control that has a requery event taking three integer parameters. The FillDataTable method in the BO looks like this: public void FillByOrderIndex(int pPLType, int pMasterIndex, int pAddrIndex) { SqlParameter mPLType = new SqlParameter("@pltype", pPLType); SqlParameter mMasterIndex = new SqlParameter("@masterindex", pMasterIndex); SqlParameter mAddrIndex = new SqlParameter("@addrindex", pAddrIndex); FillByStoredProcedure("spx_GetOrderItemList", mPLType, mMasterIndex, mAddrIndex); }This actually works (thanks for the help earlier this week!). The problem comes in when the combobox hits one of the resulting columns. It is the "orderid" field. It gets to the following code:
[Browsable(false), BusinessFieldDisplayInEditor(), Description(""), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public System.Int32 orderid { get { return (System.Int32)this.CurrentRow["orderid"]; <--*** OFFENDING CODE *** } set { this.CurrentRow["orderid"] = value; } } The get_orderid() method kicks out a "Specified cast is not valid" error. If I place the parameters into the SQL Query Analyzer, I get a result set that does have an orderid and it is an integer value. Any ideas about what I should do or where to look for a solution?
Thanks!! Bill
|
| | | | StrataFrame VIP
       
Group: StrataFrame Users Last Login: Yesterday @ 6:42:41 PM Posts: 1,058, Visits: 2,581 |
| | Have you put a break point on that line and investigated what the value of this.CurrentRow["orderid"] is? |
| | | | StrataFrame User
       
Group: StrataFrame Users Last Login: Yesterday @ 3:00:39 PM Posts: 244, Visits: 816 |
| | Yup...that is why this is so baffling...the loValue variable is reflecting the value of the integer field properly. Yet, the stack trace shows that get_orderid method throws a specified cast is not valid error. Scratches head (again). |
| | | | StrataFrame User
       
Group: StrataFrame Users Last Login: Yesterday @ 3:00:39 PM Posts: 244, Visits: 816 |
| | Sorry...I changed the field to return a 0 on null, so the code looks like this, now: [ Browsable(false), BusinessFieldDisplayInEditor(), Description(""), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public System.Int32 orderid { get { object loValue; loValue = this.CurrentRow["orderid"]; if (loValue == DBNull.Value) { return 0; } else { return (System.Int32)loValue; } } set { this.CurrentRow["orderid"] = value; } } |
| | | | StrataFrame VIP
       
Group: StrataFrame Users Last Login: Yesterday @ 6:42:41 PM Posts: 1,058, Visits: 2,581 |
| | This fixed it or this is what the code looks like now? I see nothing obviously wrong. The most likely problems are either the BO is empty (in which case CurrentRow is null) or the value of the field is DbNull.Value, which you're taking care of. |
| | | | StrataFrame User
       
Group: StrataFrame Users Last Login: Yesterday @ 3:00:39 PM Posts: 244, Visits: 816 |
| Still broken.
I am still trying to change one thing at a time to correct the problem (very time-consuming). So far, no success. Thanks for pitching in, Greg. I am sure I did something wrong that is quite simple and easily overlooked. I see a "Doh!" moment coming soon.Bill |
| | | | StrataFrame User
       
Group: StrataFrame Users Last Login: Yesterday @ 3:00:39 PM Posts: 244, Visits: 816 |
| | Here is the error report: InvalidCastException Specified cast is not valid. Source : System Stack Trace: at System.ComponentModel.ReflectPropertyDescriptor.SetValue(Object component, Object value) at System.Windows.Forms.Binding.SetPropValue(Object value) at System.Windows.Forms.Binding.PushData(Boolean force) at System.Windows.Forms.Binding.UpdateIsBinding() at System.Windows.Forms.Binding.CheckBinding() at System.Windows.Forms.Binding.SetListManager(BindingManagerBase bindingManagerBase) at System.Windows.Forms.ListManagerBindingsCollection.AddCore(Binding dataBinding) at System.Windows.Forms.BindingsCollection.Add(Binding binding) at System.Windows.Forms.BindingContext.UpdateBinding(BindingContext newBindingContext, Binding binding) at System.Windows.Forms.Control.UpdateBindings() at System.Windows.Forms.Control.OnBindingContextChanged(EventArgs e) at System.Windows.Forms.Control.OnParentBindingContextChanged(EventArgs e) at System.Windows.Forms.ContainerControl.OnCreateControl() at System.Windows.Forms.Form.OnCreateControl() at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible) at System.Windows.Forms.Control.CreateControl() at System.Windows.Forms.Control.WmShowWindow(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ScrollableControl.WndProc(Message& m) at System.Windows.Forms.ContainerControl.WndProc(Message& m) at System.Windows.Forms.Form.WmShowWindow(Message& m) at System.Windows.Forms.Form.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativewindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativewindow.WndProc(Message& m) at System.Windows.Forms.Nativewindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
|
| | | | StrataFrame VIP
       
Group: StrataFrame Users Last Login: Yesterday @ 6:42:41 PM Posts: 1,058, Visits: 2,581 |
| | Did you set the FieldPropertyDescriptor for this property? |
| |
|
|