Vtable.FieldCount problem was: Illegal Cast Exception

Steve Albin steve at steve-albin.com
Sat Oct 17 10:08:07 CDT 2009


On 10/17/09 at 10:41 AM, ruslan_zasukhin at valentina-db.com 
(Ruslan Zasukhin) wrote:

>On 10/17/09 3:36 PM, "Steve Albin" <steve at steve-albin.com> wrote:
>
>Hi Steve,
>
>>Yes, I agree that some of my code is poorly written.  Some of it
>>goes back to Valentina 1.  I am updating my code to improve it
>>as I go along.   But this isn't the problem I have now.  In my
>>follow up email, I mentioned that the problem was the result of
>>an incorrect result returned by VTable.FieldCount.  What about that?
>>
>>My project worked fine using V4RB 4.1.  I changed nothing but
>>installed V4RB 4.3 and rebuilt the project.  Why would
>>FieldCount work in 4.1 and not in 4.3?  I see nothing in release
>>notes mentioning a change to FieldCount.
>
>Yes, no changes here ... Simplest kind property ...
>
>>I will create a small project and submit to Mantis.
>
>Ok, because all our tests go fine.
>
>Your db diagnose is fine?
>Vstudio show all fields?
>
>
>Also I wonder, you say you use cursor and SELECT,
>Then why you also use Vtable.FieldCount?
>If you use SQL, then more correct is to use Vcursor.FieldCount()

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.

Steve


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



More information about the Valentina mailing list