Reading RecID after Add()

Charles Yeomans yeomans at desuetude.com
Mon Feb 23 13:49:24 CST 2004


On Feb 23, 2004, at 12:47 PM, James Milne wrote:

> Hi Guys,
>
> I'm wanting to insert a record into a table after having used an empty
> cursor to insert it, like so:
>
>   Dim statement as String
>   Dim resultSet as VCursor
>   Dim recordId as Integer
>
>   ' Create statement to get empty resultset
>   statement = "select RecID, * from timeline where RecID = 0"
>
>   ' Execute statement to get empty resultset
>   resultSet = me.db.SqlSelect( statement, kV_Client, kV_ReadWrite )
>   if (resultSet = nil) then
>     return nil
>   end if
>
>   ' Clear this cursor
>   resultSet.SetBlank()
>
>   ' Set the fields of the cursor ready to create a record
>   resultSet.VarcharField("name") = inName
>
>   ' Create this recored
>   if not resultSet.Add() then
>     return nil
>   end if
>
>   if not resultSet.Update() then
>     return nil
>   end if
>
> After the Add, I want to read the RecID generated back out. Will this 
> work
> correctly?
>
>   ' Read the record ID
>   recordId = resultSet.ULongField("RecID")
>

Yep.

Charles Yeomans



More information about the Valentina mailing list