[V4RB-Vserve] what is the fastest add records method?

Eric Ferrer wonderfef at noos.fr
Mon Jan 31 15:11:06 CST 2005


Hello all,

I have to add several records (up to 100) in a single method.

Basically, the user enters some values in a Listbox, with many rows and 10
columns).
When she wants to save, a method loops into all rows and records, and adds
as many records that there are rows in the listbox.

I use this kind of method :

Dim r, c as integer
Dim field, value as string
Dim cursor as Vcursor

' create a non nil cursor with no records in the good table:
Cursor = thedatabase.SQLSelect("SELECT * FROM myTable WHERE myField =
'whatever'", 2, 1, 1)

For r = 0 to ListBox1.listcount - 1

    cursor.setblank

    for c = 0 to ListBox1.columncount-1

        field = ListBox1.heading( c )
        value = ListBox1.cell(r, c)

        cursor.field(field).setstring value

    next

    if cursor.update = false then
        MsgBox "oops"
    end if

Next

But this runs surprisingly slowly. I used to seeing Valentina running much
faster than that.

Thus this kind of method runs fast for updates.

Is there a faster method?

I think that SQLExecutes are too dangerous, because they may update all the
records in the table if the "WHERE" statement is skipped for any reason.

Thanks all
Eric






More information about the Valentina mailing list