ComboBoxEdit Requery Event Failing


Author
Message
Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
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

Greg McGuffey
Greg McGuffey
Strategic Support Team Member (4.8K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
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.
Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
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;
    }
}


Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
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).

Greg McGuffey
Greg McGuffey
Strategic Support Team Member (4.8K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Have you put a break point on that line and investigated what the value of this.CurrentRow["orderid"] is?
Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)
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



GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search