Vtable.FieldCount problem was: Illegal Cast Exception

Steve Albin steve at steve-albin.com
Sat Oct 17 16:11:03 CDT 2009


The fix was very simple.  Below is the code in a contructor for 
one of my subclasses of VTable:

Sub Constructor()
// Calling the overridden superclass constructor.
Super.Constructor( "Labels" )

'self.name = "Labels"
// Make fields of the Table
self.nId = new VULong( "nId",  EVFlag.fUnique + EVFlag.fIndexed )
self.cLabel = new VVarChar( "cLabel",  100, EVFlag.fIndexed )
self.cCntryCode = new VString( "cCntryCode",  5, EVFlag.fIndexed )
End Sub

If you notice, I have commented out where I as assigning 
"Labels" to the name property.  That was the old way.  The new 
way is to call the Super and pass the value for name.  That is 
what I added to update the code for version 4.3 and that is how 
it is done in the examples.

People new to Valentina or those making new applications will 
probably not run into this situation since RB will automatically 
add this call for you when you are creating the new class.  The 
reason it slipped past me is that I was using classes that were 
coded back in the days I was using Valentina 1.

Steve


--
Steve Albin - Montclair, NJ  - USA
http://www.jazzdiscography.com/
http://www.steve-albin.com/


On 10/18/09 at 5:06 PM, BarrySum at BigPond.Net.AU (Barry G. 
Sumpter) wrote:

>Hi Steve,
>
>I enjoy reading the issues and the solutions.
>So please feel free to post as you see fit.
>
>Any chance of you posting the code snippet before and after the fix?
>As I too went thru conversion issues.
>
>Looking forward to any further posts.
>
>baz
>
>
>-----Original Message-----
>From: valentina-bounces at lists.macserve.net
>[mailto:valentina-bounces at lists.macserve.net] On Behalf Of Steve Albin
>Sent: Sunday, 18 October 2009 5:53 AM
>To: Valentina Developers
>Subject: Re: Vtable.FieldCount problem was: Illegal Cast Exception
>On 10/17/09 at 11:08 AM, steve at steve-albin.com (Steve Albin) wrote:
>
>>Unfortunately, my app is a mixed bag of techniques that has 
>>changed as I learned more.  I've been working on it since the 
>>days of Valentina 1.  I use SQL to create my cursors and then 
>>use VCursor classes to access the data.  It's worked fine for 
>>me up to now.
>>
>>I'm using the vTable.FieldCount property when I need to access 
>>fields from a SELECT statement that combines two tables.  I 
>>generally do this:
>>
>>cursor.SqlExecute("SELECT tableA.*, tableB.fld1, tableB.fld2")
>>
>>Then I get the FieldCount of TableA so I can do this:
>>
>>return cursor.Field(DB.TableA.FieldCount+1).GetString
>>
>>to get tableB.fld1 without having to worry about changing that 
>>code if I ever add fields to TableA.
>>
>>I've submitted a project and DB to Mantis that demonstrates 
>>the problem.  ID = 0004590.
>
>
>Just for the record, this turned out to be a problem in my code 
>and not with Valentina.
>
>In the release notes, there is an item mentioning a fix to a 
>VTable constructor issue.  I was not calling the 
>Super.constructor in my VTable classes.  In version 4.1, this 
>was not necessary.  Evidently, in version 4.3, it is necessary.
>
>Without calling the super, when creating a DB you get a DB with 
>no tables.  But, when opening an existing DB, everything works 
>except any method calls to the class.  I was only using the 
>classes to open the DB and a few other minor things.  All my 
>SQL and other API calls were fine.
>
>Sorry for any confusion I may have caused.
>
>Steve
>



More information about the Valentina mailing list