add a record

Ruslan Zasukhin sunshine at public.kherson.ua
Sat Jul 1 00:18:04 CDT 2006


On 6/30/06 5:16 PM, "Sylvain Perque" <sylvain.perque at ac-reims.fr> wrote:

> Hi,
> I can't find what i do wrong. A error occure after I close the base.
> If I keep it open, there is not error.
> The code for one field :
> ---------------------------------------------------------------------
> Valentina = new (Xtra("Valentina"))
> Valentina.Init(200 * 1024, "", "")
> gDb = new (Xtra "VDatabase", #kLocal)
> gDb.open("My Path\Name of my db.vdb")

ok

> -- To add records to the table we need build a cursor using SQL query.
> query = "select * from Resultats WHERE false"

ok

> -- This is the new way to build a cursor
> gCursor = gDb.sqlSelect(query, #kServer, #kReadWrite, #kRandom)

ok

> tblRes = gDb.table("Resultats")
> vTDBNom = tblRes.field("TDBName")
> RecID = tblRes.addRecord()
> tblRes.flush()

Oops. Few mistakes here

1) if you want use cursor to add a record, then you do not need Table.

2) you do Vtable.addrecord, but where you have assign fields ??

Must be something as

   gCursor = gDb.sqlSelect(query, #kServer, #kReadWrite, #kRandom)

    gCursor.SetBlank()
    gCursor.Field("TDBName").value = ...
    gCursor.AddRecord

Or can be simply via SQL

    gDB.SqlExecute( "INSERT INTO Resultats (TDBName) VALUES(v1) " )

If you can do simple INSERT, no need produce cursor...


 
> -- close
> gCursor = void
> gDb.close()
> gDb = void
> if objectP(Valentina) then
> -- When we finish work with Valentina engine we should shutdown it.
> Valentina.shutDown()
> end if
> -----------------------------------------
> thanks to help a so newbie.

-- 
Best regards,

Ruslan Zasukhin
VP Engineering and New Technology
Paradigma Software, Inc

Valentina - Joining Worlds of Information
http://www.paradigmasoft.com

[I feel the need: the need for speed]




More information about the Valentina mailing list