🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: free.it.visual-basic
Article #2176

Re: *** Recordset Open o Close ??? ***

#2176
From: Matteo
Date: Mon, 08 Sep 2003 22:13
59 lines
2703 bytes
Ti da errore semplicemente perch� tenti di aprire un recordset gi� aperto o
di chiudere un recordest gi� chiuso.

Ci sono diverse strade per evitare questo.
La prima � di aprire un recordset, completare l'operazione che si vuole
svolgere e poi chiuderlo immediatamente, eviti cosi di perderti.

L'altra � quella di verificare prima di chiudere o di aprire un recordset il
suo stato attuale con l'istruzione:

if nomeAdodb.recordset.state = adStateClosed then
    nomeAdodb.recordset.open
end if

oppure

if nomeAdodb.recordset.state = adStateOpen then
    nomeAdodb.recordset.Close
end if

Ciao Matteo

"Saimon" <saimon181072@yahoo.it> ha scritto nel messaggio
news:bg84c7$v3p$1@newsreader.mailgate.org...
> Come mai a volte il programma mi da errore perch� l'oggetto � aperto e a
> volte l'oggetto � chiuso ???
>
> Non ho riportato la funzione di apertura connessione al DB...
>
> Dim cn as New ADODB.Connection
> Dim rs as New ADODB.Recordset
>
> On error resume next
>
> Sql = "SELECT * FROM calendario"
>   rs.open sql,cn,adOpenStatic, adLockOptimistic
>   If Err.Number <> 0 Then
>     MsgBox Err.Description
>     Exit Function
>   End If
>
> If Not rs.EOF Then
>     Sql = "DELETE * from CALENDARIO"
>     rs.open sql,cn,adOpenStatic, adLockOptimistic
>     If Err.Number <> 0 Then
>       MsgBox Err.Description
>       Exit Function
>     End If
>   End If
>
>   Sql = "SELECT * FROM calendario"
>   rs.Open Sql, cn, adOpenStatic, adLockOptimistic
>   If Err.Number <> 0 Then
>     MsgBox Err.Description
>     Exit Function
>   End If
>
>
>
Technical Details
Message-ID: <Da77b.303668$lK4.9495434@twister1.libero.it>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-04!sn-xit-06!sn-xit-08!supernews.com!news.tele.dk!news.tele.dk!small.news.tele.dk!news.mailgate.org!nntp.infostrada.it!twister1.libero.it.POSTED!not-for-mail
References: <bg84c7$v3p$1@newsreader.mailgate.org>

Show Full Headers
Complete Article Headers
X-Google-Language: ITALIAN,ASCII
X-Google-Thread: f94ee,da326d5251d5c643
X-Google-Attributes: gidf94ee,public
X-Google-ArrivalTime: 2003-09-08 15:16:34 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-04!sn-xit-06!sn-xit-08!supernews.com!news.tele.dk!news.tele.dk!small.news.tele.dk!news.mailgate.org!nntp.infostrada.it!twister1.libero.it.POSTED!not-for-mail
From: "Matteo" <NOSPAMmatteopandin@libero.it>
Newsgroups: free.it.visual-basic
References: <bg84c7$v3p$1@newsreader.mailgate.org>
Subject: Re: *** Recordset Open o Close ??? ***
Lines: 61
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
Message-ID: <Da77b.303668$lK4.9495434@twister1.libero.it>
Date: Mon, 08 Sep 2003 22:13:55 GMT
NNTP-Posting-Host: 151.25.90.217
X-Complaints-To: abuse@libero.it
X-Trace: twister1.libero.it 1063059235 151.25.90.217 (Tue, 09 Sep 2003 00:13:55 MET DST)
NNTP-Posting-Date: Tue, 09 Sep 2003 00:13:55 MET DST
Organization: [Infostrada]