[V4RB] Copying one record to another Valentina DB

Fred.Stephenson Fred.Stephenson at wanadoo.fr
Fri May 16 11:15:33 CDT 2003


>>  perhaps you could give a bit more info (code) so that we can see what
>>  needs improving ??
>
>To give more details, the first database contains the main data of my
>programm, and the second one runs like an archive.
>Let's call them 'maindata.vdb' and 'archive.vdb'

so I suppose that you're doing something like

For x= 1 to maindata.baseobjectscount
MainBo=maindata.baseobject(x).name
If archive.baseobject(mainbo) <> nil then
   If  archive.baseobject(mainbo).fieldcount < 
maindata.baseobject(x).fieldcount then
   //create missing fields
  end if
else
//create Bo+ fields
end if

Cursor = maindata.SQLSelect("SELECT * from "+Mainbo+ " WHERE myBooleanField =
TRUE")
if cursor.firstrecord then
do

     vbo.SetBlank

     for i = 1 to cursor.FieldCount

       fieldname = cursor.Field(i).Name

       vbo.field(fieldname).SetString(cursor.Field(fieldname).GetString)

     next

     vbo.AddRecord()

   loop until cursor.NextRecord = false
end if

next


>
>All records deleted in the maindata.vdb are copied in the archive.vdb before
>being deleted.
>
>Dim cursor as Vcursor
>Dim i as integer
>Dim vbo as VBaseObject
>Dim fieldName as string
>
>Cursor = maindata.SQLSelect("SELECT * from myTable WHERE myBooleanField =
>TRUE)
>
>If cursor.recordcount = 0 then
>     return
>End if
>
>'here I create the same BaseObject from maindata.vdb in archive.vdb if it
>does not exist already.
>'vbo then equals to the corresponding BaseObject in archive.vdb
>
>For i = 1 to cursor.fieldcount
>  'here I have code that detect if fields from maindata.vdb exist in
>archive.vdb
>  ' it creates fields if necessary
>Next
>
>///////// Now I copy the data from the cursor to archive.vdb
>   do
>
>     vbo.SetBlank
>
>     for i = 1 to cursor.FieldCount
>
>       fieldname = cursor.Field(i).Name
>
>       vbo.field(fieldname).SetString(cursor.Field(fieldname).GetString)
>
>     next
>
>     vbo.AddRecord()
>
>   loop until cursor.NextRecord = false
>
>
>Thanks for your help
>Eric
>
>_______________________________________________
>Valentina mailing list
>Valentina at lists.macserve.net
>http://lists.macserve.net/mailman/listinfo/valentina


More information about the Valentina mailing list