Exception has been thrown by the target of an invocation.


Author
Message
Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
EUREKA!!  w00t w00t w00t

Instead of evaulating the object against null, I must evaluate the object against DBNull.Value.  Wow!  How did I miss that?!?!  Perhaps I have a vitamin difficiency somewhere.

Now, I will reintroduce the DevEx grid and see if this solution applies there, too.

To quote Paul Harvey, "Stand by for news!"

Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
Stop the presses!  The DevEx XtraGrid is not behaving.  It still pops the generic error when either accessing the column (CurrInvQty) or simply closing the window.  No additional information or debug data available.

Sad.  Truly sad.  Thought I had it.  Crying

I am still needing help on this one.  It would be great if a DevEx user chimes in here and let's me know how they solved their custom property issues with the DevEx grid.

I must keep at this...now is not the time to cash in my 401K and retire. BigGrin

Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.4K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Bill,



Doubt that this is it, but you probably ought to check value against null AND DbNull.Value, in that order. The first checks if any record was returned, the second if the value returned was NULL. Again, I doubt this is your problem, but it could bite you at some point.
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Without you setting up a sample that reproduces the behavior it is going to be hard for me to tell you what to do exactly.  I do know, however, that this is more than likely something that needs to be first addressed in the BO to account for NULLs, and then you may have to set a property somewhere in the grid if the problem persists...so past some of the recommendations that I have made or Greg has made it is going to be hard to give you any answers....sorry Ermm
Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
I did provide a sample project that does exactly what I am describing (see earlier post).  I will try the double null/DBNull.value check.  Thanks.
Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
if (loValue == null || loValue == DBNull.Value)

This does not change anything.

Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
I ran your sample, and it did not work.  Not SF, but your query would not ever work.  I did reproduce your problem once I made the query work.  The bottom line is that you are using a this.CurrentRow["ItemsCount"] without actually having that column in the data table.  When the Dispose fires, that strong-type field is being evaluated and thus the error.

I have reattached the sample (I had to change the references to 8.1 since I haven't dowloaded 8.2).  But this had nothing to do with the grid or or SF for that matter. 

If you want to reference a field in the data table, make sure it is there otherwise the error will occur.  You can also do real-time aggregate calculations if you have the need when the property is evaluated....though you could run into performance issues there if an additional query is taking place.

Also, your query would not work

SELECT * AS ItemsCount FROM Movies

That query will never work since you cannot place a wildcard into a single column name.  I changed to this just to create the column, but you could do a query and figure out your aggregates, etc.

SELECT Movies.*, Movies.mv_pk AS ItemsCount FROM Movies

I know that pushing the PK into this column doesn't do anything of value here, but it should at least get the point across.

But in regards to your problem, that was it here.

Attachments
DataGridTest.zip (128 views, 125.00 KB)
Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
Please read all of my posts...I am trying to be as thorough as I can so I can get the surgical, precision-type help that I need.

The thread immediately following my sample post explained the incorrect SQL that was in the sample.

And, yes, I also subsequently provided information about manually adding the column to the datatable during data table initialization or refill.  It appeared to solve the problem in the test sample, but failed to solve the problem in my application.

If the column exists because I manually add it, then I get the casting problem. 

Using either a check on "null" and/or "DBNull.Value" does nothing to get me past the error.

The error popup does not supply any debug information.  I am lost when it comes to "seeing" what actually is causing the problem.  I am assuming a casting issue because the DataGridView responds with more information which I assume is the same problem that the DevEx GridView is having.  Big assumption on my part, I think.

I'll keep trying and continue to post results on this thread.

Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
When the Dispose fires, that strong-type field is being evaluated and thus the error.

This statement intrigues me.  If the custom property object is null then the return value is always zero (0) of type decimal.  Why would there be an error thrown at that time?  It is not thrown when the object is created.

Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
Change this . . .


public void FillAll()
{
    FillDataTable(
"SELECT Movies.*, mv_pk As ItemsCount FROM Movies");
}

. . . to this . . .


public void FillAll()
{
    FillDataTable(
"SELECT Movies.* FROM Movies");
}

. . . and the error occurs.  I do not understand.  The column should evaluate as null, therefore return a value of zero.  Why does this error?  What if all I wanted was to list the movie titles (SELECT mv_Title FROM Movies) and display the results in a grid, would this not be a valid query since custom properties are involved in the BO?  Should I always have to fill the custom properties with something (SELECT mv_Title, 0 AS ItemCount FROM Movies) even if I am not going to reference the custom property(-ies), or any other property (e.g. mv_Year, mv_Rating, etc.)?

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