Skip site navigation (1) Skip section navigation (2)

RE: [ODBC] Visual Basic and PostgreSQL ODBC

From: Dave Page <dpage(at)vale-housing(dot)co(dot)uk>
To: "'Ryan C(dot) Bonham'" <Ryan(at)srfarms(dot)com>, pgsql-odbc(at)postgresql(dot)org
Cc: pgsql-general(at)postgresql(dot)org
Subject: RE: [ODBC] Visual Basic and PostgreSQL ODBC
Date: 2001-07-30 07:19:38
Message-ID: 8568FC767B4AD311AC33006097BCD3D61A2D56@woody.vale-housing.co.uk (view raw or flat)
Thread:
Lists: pgsql-generalpgsql-odbc

> -----Original Message-----
> From: Ryan C. Bonham [mailto:Ryan(at)srfarms(dot)com] 
> Sent: 27 July 2001 18:00
> To: pgsql-odbc(at)postgresql(dot)org
> Cc: pgsql-general(at)postgresql(dot)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

Next:From: Henshall, Stuart - WCPDate: 2001-07-30 08:34:37
Subject: RE: A problem with the nextval('') function
Previous:From: Dave PageDate: 2001-07-30 07:11:33
Subject: RE: Error with DECIMAL or NUMERIC data type

pgsql-general by date

Next:From: Kapil TilwaniDate: 2001-07-30 12:31:11
Subject: C / FoxPro
Previous:From: Hiroshi InoueDate: 2001-07-30 07:19:20
Subject: Re: Re: "Oracle's ROWNUM"

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group