Bill Cunnien
|
|
Group: Forum Members
Posts: 785,
Visits: 3.6K
|
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
|
|
|
Bill Cunnien
|
|
Group: Forum Members
Posts: 785,
Visits: 3.6K
|
Not exactly sure what you are talking about...sorry. After you mentioned that, though, I went into the DDT and edited my (non-database) table. I put a description in each column (same as the name). Partial built and this is now the code in the BO for the orderid: [ Browsable(false), BusinessFieldDisplayInEditor(), Description("orderid"), 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; <<--- BOMBS HERE! } } set { this.CurrentRow["orderid"] = value; } }I am building and running now...stand by... Btw, I blew away the combobox and added a grid, bo and bbs. No matter what I do, the orderid bombs. Here is the error: System.InvalidCastException was unhandled by user code Message="Specified cast is not valid." Source="AspireModel" StackTrace: at Aspire.Model.OrderItemListBO.get_orderid() in C:\Aspire Projects\AspireSF\AspireModel\OrderItemListBO.Designer.cs:line 315 at Aspire.Model.OrderItemListBO.Field_orderid_Descriptor.GetValue(Object component) in C:\Aspire Projects\AspireSF\AspireModel\OrderItemListBO.Designer.cs:line 575 at DevExpress.Data.Helpers.BaseListDataControllerHelper.GetRowValue(Int32 listSourceRow, Int32 column) at DevExpress.Data.DataController.GetRowValue(Int32 controllerRow, Int32 column) at DevExpress.Data.BaseListSourceDataController.GetRowValue(Int32 controllerRow, Int32 column) at DevExpress.XtraGrid.Views.Base.ColumnView.GetRowCellValue(Int32 rowHandle, GridColumn column) at DevExpress.XtraGrid.Views.Grid.GridView.GetRowCellValue(Int32 rowHandle, GridColumn column) at DevExpress.XtraGrid.Views.Grid.ViewInfo.GridViewInfo.CalcRowCellDrawInfo(GridDataRowInfo ri, GridColumnInfoArgs ci, GridCellInfo cell, GridColumnInfoArgs nextColumn, Boolean calcEditInfo) at DevExpress.XtraGrid.Views.Grid.ViewInfo.GridViewInfo.CalcRowCellsDrawInfo(GridDataRowInfo ri, GridColumnsInfo columnsInfo) at DevExpress.XtraGrid.Views.Grid.ViewInfo.GridViewInfo.CalcDataRow(GridDataRowInfo ri, GridRow row, GridRow nextRow) at DevExpress.XtraGrid.Views.Grid.ViewInfo.GridViewInfo.CalcRowsDrawInfo() at DevExpress.XtraGrid.Views.Grid.ViewInfo.GridViewInfo.CalcGridInfo() at DevExpress.XtraGrid.Views.Grid.ViewInfo.GridViewInfo.Calc(Graphics g, Rectangle bounds) at DevExpress.XtraGrid.Views.Base.ColumnView.DoInternalLayout() at DevExpress.XtraGrid.Views.Base.ColumnView.CalculateLayout() at DevExpress.XtraGrid.Views.Grid.GridView.LayoutChanged() at DevExpress.XtraGrid.Views.Base.BaseView.EndUpdateCore(Boolean synchronized) at DevExpress.XtraGrid.GridControl.EndUpdate(Boolean synchronized)
|
|
|
Greg McGuffey
|
|
Group: Forum Members
Posts: 2K,
Visits: 6.6K
|
Take a look at this post, you've got the property setup, just wondering if you also added the field property descriptors for any custom fields: http://forum.strataframe.net/FindPost13027.aspx
|
|
|
Bill Cunnien
|
|
Group: Forum Members
Posts: 785,
Visits: 3.6K
|
I am defining the table in DDT, creating a BO, then pointing the BO to the table via the BOM. These are derived fields from the DB, to be sure, but they are technically not custom. I don't think I would need custom bindable property descriptors. I'll take a look at this.
|
|
|
Bill Cunnien
|
|
Group: Forum Members
Posts: 785,
Visits: 3.6K
|
The BO isn't even completed with the data retrieval method and I get this: orderid = 'this.orderid' threw an exception of type 'System.InvalidCastException' The orderid field is set to INT. The field that I am retrieving to fill the table is an INT, as well. This is quite confusing. I am going to blow away the table, the BO and the references on the form to the BO and start over. I have been working on this for almost 6 hours. I doubt starting from scratch will make any difference.  Btw, I have confirmed that the stored procedure used to fill the table works perfectly. An orderid is being returned that is an INT. Confusing. Bill
|
|
|
Bill Cunnien
|
|
Group: Forum Members
Posts: 785,
Visits: 3.6K
|
Added a watch to the variable loValue (which looked like it had a value). It shows this: loValue 0x0000000000004ff8 object {long}
Long?!? The type ought to be Int. Hmmmm. Maybe I am on to something here...
|
|
|
Bill Cunnien
|
|
Group: Forum Members
Posts: 785,
Visits: 3.6K
|
The table in SQL Server has the orderid field defined as INT. That field is selected in a stored procedure, like this: SalesOrderMaster.orderid AS orderid When I saw that the field was showing up in the BO as a LONG, I did this: CAST(SalesOrderMaster.orderid AS int) AS orderid Now, it works. This is a SQL Server 2000 application. Could anyone provide a reason for this kind of behavior? Thanks! Bill
|
|
|
Trent Taylor
|
|
Group: StrataFrame Developers
Posts: 6.6K,
Visits: 7K
|
Now, it works. This is a SQL Server 2000 application. Could anyone provide a reason for this kind of behavior? I would have to set this up on an SQL Server 2000 machine...but it was actually SQL Server passing it over as long...not the BO converting the value. It has been a while since I lived in SQL Server 2000 as we only use 2005 (and soon 2008) any more in the field. However, if I am not mistaken, I think that when a field was derived in SQL Server 2000 and it was not explicity defined in a variable or from an underlying field table, it always went the the larger of the values...in this case LONG (BIGINT) over INT. I would have to get my head back into the older rules...but at any rate, I am glad you got it figured out. Now you have my curiosity up...I will have to load a 2000 machine up and give it a go
|
|
|
Bill Cunnien
|
|
Group: Forum Members
Posts: 785,
Visits: 3.6K
|
Thanks for the response. I long to be on SQL Server 2008. Our adoption of newer versions is a bit slow. I did get authorization to obtain SS2008 for installation and migration later this summer. I expect to be blown away by the improvements. But, I also expect a good chunk of work getting all of the databases relocated. It will be fun work, though!
|
|
|