Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

.NET array of rows Invalid Cast error (on some machines)

Posted on 2005-05-09
19
Medium Priority
?
199 Views
Last Modified: 2010-04-17
Here's my situation.  We've developed a Web Service that generates a strongly typed dataset consisting of mutiple tables - all strongly typed.  When running a select statment against a DB2 mainframe which returns a rowset (or array or rows) the return values are cast as an array of rows.  This function(s) works beautifully on the server but when trying to run the code locally it fails with an 'Invalid Cast" error.  Further complicating the issue is that I can successfully debug the code on some machines but not others and yes, I've confirmed it the same #*@&#(* code.  The machine that it runs on successfully is a P3 laptop 1.2 mhz.  The machine that it fails on is a P4 2.8??   I'm running VS.NET version 2002 - Framework 1.0.    This codes was also tested on a Celeron machine and failed there also.  Is it truly a cpu issue? or a setup issue or ?    Any clues would be appreciated.

Thanks,
tree
0
Comment
Question by:treemusic
  • 9
  • 4
  • 4
  • +1
18 Comments
 
LVL 25

Expert Comment

by:InteractiveMind
ID: 13961561
tree,

Very odd indeed; what language are you using?
0
 

Author Comment

by:treemusic
ID: 13962217
C#
0
 
LVL 25

Expert Comment

by:InteractiveMind
ID: 13962454
Hmm.

Please post some code (if the following link don't help):

  http://www.dotnet247.com/247reference/msgs/11/56508.aspx
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:treemusic
ID: 13962696
Code below.  Another thing I've noticed.  Most of the time if I pf5 to run the application on my desktop, if I've previously run in debug mode, I have to bring up task manager and kill aspnet_wp.exe in order to re-compile.  I don't seem to have this issue on the laptop P3 that works.

private void RemoveDependents(ref dsMyHealthPlan oDS)
            {
                  try
                  {
                        dsMyHealthPlan.DEPCTRTRow[] _rows;
                  
                        for (int i = 0; i < oDS.DEPENDT.Rows.Count; i++)
                        {
------  Invalid Cast ERROR (start) -----
                              _rows = (dsMyHealthPlan.DEPCTRTRow[])oDS.DEPCTRT.Select("depndNo = '" +
                                    oDS.DEPENDT[i].depndNo + "' and depCtrCanclDate = 'Current'");
-----  Invalid Cast Error (end) ---
      
                              if (_rows.Length == 0)
                              {                                    
                                    RemovePastNinetyDays(ref oDS, oDS.DEPENDT[i].depndNo);
                                    
                                    dsMyHealthPlan.DEPCTRTRow[] _tempRows = (dsMyHealthPlan.DEPCTRTRow[])
                                          oDS.DEPCTRT.Select("depndNo = " + oDS.DEPENDT[i].depndNo);
      
                                    if (_tempRows.Length == 0)
                                    {
                                          oDS.DEPENDT.RemoveDEPENDTRow(oDS.DEPENDT[i]);
                                          i = -1;
                                    }
                              }
                        }
                        _rows = null;
                  }
                  catch (Exception ex)
                  {
                        throw ex;
                  }
            }
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 13962809
Is oDS.DEPENDT[i].depndNo numeric or string?  If it is numeric, then don't use the single quote delimiter (').

Bob
0
 

Author Comment

by:treemusic
ID: 13962880
Its a string (as far as the dB is concerned).  Additionally, this code works on the server and some PC's/Laptops.

Perhaps it's a configuration issue?  Configuration of VS Studio not the Web.config file.  Or if the application was installed wrong?  I'm just throwing out possibilities here...
0
 
LVL 25

Expert Comment

by:InteractiveMind
ID: 13962894
I'd consider reinstalling VS Studio.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 13962900
As a test, does this work?

DataRows[] _rows = oDS.DEPCTRT.Select("depndNo = '" +
                              oDS.DEPENDT[i].depndNo + "' and depCtrCanclDate = 'Current'");

Bob
0
 

Author Comment

by:treemusic
ID: 13962970
No
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 13967094
Do they all have the same MDAC version?

Bob
0
 

Author Comment

by:treemusic
ID: 13967968
I would guess probably not.  Were do I find which version is loaded?
0
 

Author Comment

by:treemusic
ID: 13967999
Never Mind. Found how to find MDAC version.

http://seer.support.veritas.com/docs/190866.htm
0
 

Author Comment

by:treemusic
ID: 13968048
Damn.  Both machines are running 2.0.0

Different Rollbackversions although the SavedRollbackVersion are the same.  
Same FullInstallVersion on both machines.   #*@#&#&$*** (I was really hoping you had it there).
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 13969467
My suggestion would be to go with MDAC 2.8 on all machines, since it is the latest and greatest.

Bob
0
 

Author Comment

by:treemusic
ID: 13972360
I installed the latest MDAC (2.8) and it didn't have any effect.  
0
 

Author Comment

by:treemusic
ID: 13998099
GOT IT!  The solution is to rewrite the Friggin code and remove the unecessary cast!.   i.e.

Instead of:

     
                    for (int i = 0; i < oDS.DEPENDT.Rows.Count; i++)
                    {
                         _rows = (dsMyHealthPlan.DEPCTRTRow[])oDS.DEPCTRT.Select("depndNo = '" +
                              oDS.DEPENDT[i].depndNo + "' and depCtrCanclDate = 'Current'");
     
                         if (_rows.Length == 0)
                         {                            }


DO:
      for (inti = 0; i < oDS.DEPENDT.Rows.Count; i++)
      {
          if (oDS.DEPENDT[i].depndNo + " and depCtrCanclDate = 'Current'").Length == 0)
          {
          }
       }

0
 
LVL 25

Expert Comment

by:InteractiveMind
ID: 13998158
lol - nice on tree.

You'll be wanting a refund of your points. You may want to request in the Community Support, the following: "PAQ - Refund". This way, if someone has a similar problem in the future, they can see the solution that you've provided (but you still get your points back).  :-)

Laters.
Rob.
0
 

Accepted Solution

by:
OzzMod earned 0 total points
ID: 14059396
Closed, 500 points refunded.
OzzMod
Community Support Moderator (Graveyard shift)
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Starting up a Project

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question