RE: Visual Basic and PostgreSQL ODBC - Mailing list pgsql-odbc

From Dave Page
Subject RE: Visual Basic and PostgreSQL ODBC
Date
Msg-id 8568FC767B4AD311AC33006097BCD3D61A2D56@woody.vale-housing.co.uk
Whole thread Raw
In response to Visual Basic and PostgreSQL ODBC  ("Ryan C. Bonham" <Ryan@srfarms.com>)
List pgsql-odbc

> -----Original Message-----
> From: Ryan C. Bonham [mailto:Ryan@srfarms.com]
> Sent: 27 July 2001 18:00
> To: pgsql-odbc@postgresql.org
> Cc: pgsql-general@postgresql.org
> Subject: [ODBC] Visual Basic and PostgreSQL ODBC
>
>
> Hi,
>
>
> Ok I have a problem, that I need to find a fix or workaround
> for. I have a Visual Basic 6 application that calls on a
> PostgreSQL database. I have code that calls a table and runs
> a loop on it, deleting recordsets until the recordcount
> equals a certain number.. The code deletes the records fine,
> the problem is the recordcount doesn't change.. Does anyone
> know what is going on and how to fix it?  Thank you
>
>
> Ryan
>
> VB CODE
>
>         rstRecord2.MoveFirst
>     Do Until rstRecord2.RecordCount = 0
>         rstRecord2.Delete
>       rstReocrd2.MoveNext
>         Debug.Print rstRecord2.RecordCount
>     Loop

Try the following:

  rstRecord2.MoveLast
  rstRecord2.MoveFirst
  Do Until rstRecord2.RecordCount = 0
    rstRecord2.Delete
    rstRecord2.MoveNext
  Debug.Print rstRecord2.RecordCount
  Loop

The RecordCount property normally remains at zero until you've moved to the
end of the recordset, hence you need to MoveLast first. This can be a
resource issue though if you have large recordsets as this will cause the
entire recordset to be read from PostgreSQL. If you can though, you will
probably be better off executing a DELETE FROM sql query, and then
refreshing the recordset, or if you are always deleting all records in the
recordset, try:

  rstRecord2.MoveFirst
  While Not rstRecord2.EOF
    rstRecord2.Delete
    rstRecord2.MoveNext
  Wend

regards, Dave.

pgsql-odbc by date:

Previous
From: Dave Page
Date:
Subject: RE: Error with DECIMAL or NUMERIC data type
Next
From: "Henshall, Stuart - WCP"
Date:
Subject: RE: A problem with the nextval('') function