[V4RB] Table working with 1.9.7 but not with 1.9.8

Charles Yeomans yeomans at desuetude.com
Sat Sep 13 12:00:25 CDT 2003


On Saturday, September 13, 2003, at 05:50 AM, Stan Busk wrote:

> Hi,
>
> Thanks Ruslan for your response.
>
>> Am I right that you use here BaseObject API in the mix with Cursor 
>> API?
>> I have warn that this is bad idea.
>
> Yes, I make this all the time with no problems until yesterday with 
> 1.9.8
> I read many times it is better to modify the cursor records. It that 
> true? Problem is I don't know how to do this. If you can give me an 
> example with my sample code I would appreciate it a lot and I will 
> learn with it so I can make all other modifications myself. How should 
> I modify this code to use Cursor API only?
>
> Sub Prefs_SetValue(inDatabase As DB_Data, inKey As String, inValue As 
> String)
>   Dim aCursor as VCursor
>   Dim aResult As String
>   Dim aErr As Boolean
>
>   aCursor = nil
>   aCursor = inDatabase.SQLselect("Select * from Preferences where 
> PrefEntry_Name='"+inKey+"'")
>   if aCursor<>nil then
>      if aCursor.RecordCount>0 then
>         
> inDatabase.mPrefs.Update(aCursor.ULongField("PrefEntry_Record").Value, 
> inValue)
>      else
>         inDatabase.mPrefs.Add(inKey, inValue)
>      end if
>   end if
> End Sub

Here you go.

Charles Yeomans

-------------------------

dim c as VCursor

c = = inDatabase.SQLselect("Select PrefEntry_Name, PrefEntry_Record  
from Preferences where PrefEntry_Name='"+inKey+"'")
If c <> nil then
   c.Field("PrefEntry_Name").SetString inKey
   c.Field("PrefEntry_Record").setString inValue
   If c.RecordCount = 0 then
     If c.Add then
       inDatabase.mPrefs.Flush
     Else
       //handle error
      End if
   Else
     If c.Update then
       inDatabase.mPrefs.Flush
     Else
        //handle error
     End if
   End if
Else
   //handle error
End if



More information about the Valentina mailing list