V4RB and changing lengths of varchar fields programmatically

Francois Van Lerberghe fvanlerberghe at freegates.be
Fri Aug 15 11:14:38 CDT 2003


le 15-08-03 1:51, Cindy <alvin at ins.co.nz> a écrit :

> Hi All,
> 
> 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.

My code is the following, called before opening my db using my VDatabse
subclass :
  
    dim tmpDB as VDataBase
    dim table as VBaseObject
    dim fld As VField
    dim stringFld As VString  // according to the fieldType to change
    dim ok As Boolean

    tmpDB = new VDataBase     // don't use here your VDatabse subclass
    if tmpDB.Open( theFolderItemToYourDB ) then
  
        table = tmpDB.BaseObject( myTableName )
        if table <> nil then
            fld = table.Field( myFieldName )
            if fld <> nil then
                stringFld = VString(fld)      // change upon your fieldType
                stringFld.maxLength = newSize
                ok = (tmpDB.ErrNumber = 0)
             end if
        end if

    end if

    if tmpDB <> nil then
        tmpDB.Close
        tmpDB = nil
    end if

Now, I open my DB as usual.

Another thing : check your fieldType to see if your new size is allowed, but
if it's a VVarChar, I don't think you have a problem with this size.

Best regards

François Van Lerberghe
Thier Monty, 15A
B-4570 Marchin
Belgique



More information about the Valentina mailing list