[V4RB] RecID & picture fields

Francois Van Lerberghe fvanlerberghe at freegates.be
Thu Sep 9 09:04:34 CDT 2004


Hi Pedro,

le 9/09/04 7:01, Pedro fp <lists at pedro.Net.au> a écrit :

> G'day Folks
> 
> Back into Valentina & Rb programming after something of a layoff &
> having 2 problems that are killing the project.
> 
> The first is that this line ...
> 
>        dRow( i ).itemData = data.uMediumField( "RecID" ).value
> 
> in the method that loads the data causes an unexpected quit.

RecID is not an uMediumField. It's an ULongField.
Try this :
        dRow( i ).itemData = data.ULongField( "RecID" ).value

> dRow is just a container object that I'm using to hold the retrieved
> data in.
> All other setters to dRow, except the one mentioned below, work.
> RecID is explicitly included in the field list in my SQL query.
> 
> The 2nd problem is that this line ...
> 
>        dRow( i ).icon = data.PictureField( "photo" ).getPicture ' Set
> photo icon.
> 
> gives a nil object exception with no picture being retrieved.

This code seems to be correct. I think you must test nil objet before.
Try this : 
  dim tempPicture As Picture
  dim pictureField As VPicture
  tempPicture = data.PictureField( "photo" )
  if pictureField <> nil
    tempPicture = pictureField.GetPicture
  end if
  if tempPicture <> nil then
    dRow( i ).icon = tempPicture
  end if

Have you set the currentPosition to the record you want to retrieve?

> It could be that I have something wrong in the method that creates the
> record as after importing a folder of 30 images (1.1 MB) the blob file
> of my database hasn't changed in size.
> That method, in the baseobject that holds this data, is ...
> 
> Sub newPersonFromJPEG( withFile As folderItem )
>  dim dataString As string, iDate As new date, i, ln As integer, gt As
> boGlobals
> 
>  dataString = left( withFile.name, len( withFile.name ) - 4 )
>  writeLog "dataString: " + dataString
> 
>  gt = winMain.mDatabase.tGlobals
> 
>  ln = gt.lastAdded + 1
> 
>  me.setBlank
> 
>  me.fLine.value = ln
>  me.fDateAdded.set( iDate.year, iDate.month, iDate.day )
> 
>  for i = 0 to 1
>    me.fName( i ).value = titlecase( nthField( dataString, " ", i + 1 )
> )
>  next
> 
>  if countFields( dataString, " " ) > 2 then
>    me.fPayNumber.value = nthField( dataString, " ", 3 )
>  end if
> 
>  me.fPhoto.setPicture( withFile.openAsPicture, 80 )

You could test nil object with withFile.openAsPicture, just in case...

Cheers


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



More information about the Valentina mailing list