V4RB and changing lengths of varchar fields programmatically

Erik Mueller-Harder lists at praxisworks.com
Fri Aug 15 14:11:17 CDT 2003


> Can someone please give me the exact code for changing the length
> of a varchar field programmatically from Realbasic. Currently the
> length of my Key_Activities field in my Units Base Object is set
> at 3096 but I would like to double that. I have tried various
> ways but none of them seem to get past the debugger.

Hi, Cindy --

Probably the very easiest thing to do would be to change it in the Valentina application itself -- then the database is set the way you want it.

Then change it in Rb:  just change 3096 to 6192.

OK, now that I've read your question more thoroughly, I see you want a programmatic answer.  I can't give you exact code at this moment, but basically I think you'd want to:

1.  Open the database generically (i.e., without all the base object
    properties, etc., defined), with something like

    Dim f as FolderItem
    Dim vdb as VDatabase  // NOT as your subclass!
    
    f = (get folderItem of your db here)
    if not vdb.Open(f) then // error handle
    end if
    
2.  Then find your field and make your change

    Dim vc as VVarChar
    
    vc = VVarChar(vdb.baseObject("baseobjectname").field("varcharName")
    vc.maxlength = 6192

3.  Finally, close the database and re-open it your usual way, making
    sure to have changed your field's maxlength property to 6192 in your
    existing code.


*HOWEVER*, 6192 is not an efficient VarChar size; I believe you'd want to use 6136 or 6648, though my math may be off.  See the Valentina Kernel doc, page 22.

Good luck,

Erik


More information about the Valentina mailing list