Results 1 to 6 of 6
  1. #1
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    connection lost... (6.0)

    Instead to open each time the rset is possible to maintain active this rset connection during the time of code work (i have dimensioned in a module all variables of conn and rset Public)???

    attached is the code, in Sub APRI_CONNESSIONI_SQL() have the connection string:

    'If Not APERTO_DATE = "SI" Then
    SQL1 = vbNullString
    SQL1 = "SELECT DATA_SPORTELLO FROM DATE_INQ WHERE Left(DATA_SPORTELLO,4) = '" & Left(SPORTELLO_DATA, 4) & "'"
    RSSQLD.Open SQL1, CNSQL, adOpenForwardOnly, adLockReadOnly
    APERTO_DATE = "SI"
    ' End If
    'If Not APERTO_DATI = "SI" Then
    SSQL = vbNullString
    SSQL = "SELECT PROVA1 FROM DATI WHERE PROVA1 = '" & MERCATO_1 & "'"
    RSSQL1.Open SSQL, CNSQL, adOpenForwardOnly, adLockReadOnly
    APERTO_DATI = "SI"
    ' End If
    'If Not APERTO_SCHEDA = "SI" Then
    SSQL = vbNullString
    SSQL = "SELECT PROVA1 FROM SCHEDA WHERE PROVA1 = '" & PARAM_1 & "'"
    RSSQL3.Open SSQL, CNSQL, adOpenForwardOnly, adLockReadOnly
    APERTO_SCHEDA = "SI"
    ' End If

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: connection lost... (6.0)

    RSSQL3 and RSSQL1 are opened repeatedly with different where-conditions each time within the loops, so you can't just open them once.

    It is not clear in your code where SPORTELLO_DATA comes from, so I don't know about RSSQLD.

  3. #3
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: connection lost... (6.0)

    here the var public:
    Option Explicit
    Public RIGA2 As String, TOT_SCONFIN As Double
    Public SPORT As String, ID_FLUSSO As String, C_C As String, VETTORE As String, ID_FLUSSO1 As String
    Public RIGA As Long, COD_SIA As String, TEST_FINE As String, SUPPORTO As String
    Public SCARTI As String, NR_DISP As Long, Y As Integer, TROVATA As Long
    Public CONTA_STRINGA As String, C_C_SEC As String, INDICE As String, DATA_TROVATA As String
    Public TOTALE_FLUSSO, TEST_SINO As String, IMPORTO As Long
    Public g_HostSettleTime, OldSystemTimeout&, MESE_TEST, RIGA1 As Long
    Public SESSIONS As Object, TEST_MESE, Found_INDEX, StrTemplate As String
    Public SYSTEM As Object, I As Integer, TEST_REGIONE_MERCATO As String, PASSWORD As String
    Public SESS0 As Object, ULTMI_DEL_MESE, MESE_CORRENTE, PAGINA_SCELTA As String
    Public SessName0 As String, TN As Long, Z As Long, P As Long
    Public TERM As String, TEST As String, RIGAP As Long, PAGINA As Long
    Public COD_APAC, OP_DEL, PARAM_1 As String, PARAM_2 As String, MATRICOLA As String, TT As Integer
    Public SERV, RIGA_COD, CONTO As String, CONTO1 As Long, CONTO2 As Long, CONTO3 As Long
    Public VERIFICA_GIORNO, VERIFICA_MESE, DATA_SCELTA, VERIFICA_ANNO, DATA_CICSBQ
    Public NT, RECORD_CORRENTE As Long, SESSAB, SPORT_SEC As String
    Public TIPO, AGENZIA As String, DESCR_AGENZIA, NDG As String, COPE As String, NOMINATIVO As String
    Public NomeFile, iFile, TABULATO, TEST_DATA As Date, DATA_CORRENTE As Date
    Public fs As Object, MESE, DATA_TAB, ANNO, VAR_SPORT, TEMPL
    Public filespec As String, TERMINALE As String, PRN, SCELTA As String, SPORTELLO_COMBO As String
    Public FProfile$, FOGLIO, DOMANDA, SPORTELLO_DATA As String
    Public DATA_INIZIO As Long, DATA_FINE As Long, REGIONE As String
    Public NumberOfSessions As Integer, T As Integer
    Public PORTAFOGLIO As String, NUM_POS As Long, PORTAFOGLIO1 As String
    Public IMPORTO_SCARTI As String, TOT_IMPORTO_SCARTI As String
    Public Const gPROVADatabasePath = "GCD01F4500DATIPUBBLICABOUASSPAST_DUE.MDB"
    Public TEST_RECORDS As String, TEST_NODE As String, STRINGA_DATI As String
    Public strConnection As String
    Public CNN As New ADODB.Connection
    Public RST As New ADODB.Recordset
    Public RST1 As New ADODB.Recordset
    Public RST2 As New ADODB.Recordset
    Public RST3 As New ADODB.Recordset
    Public RST4 As New ADODB.Recordset
    Public NOMEDB As String, MERCATO_SEL As String, TEST_REGIONE As String
    Public SSQL As String
    Public ACCORD As Long, UTILIZ As Long, SCONF As Long, GIOR As Long
    Public SPOR As String, SETT As String, PORTAF As String, COPLIST As String
    Public NDG_T As String, MERC As String, MSEG As String, SEG As String
    Public MERCATO_1 As String, MERCATO_2 As String, MERCATO_3 As String, MERCATO_4 As String, MERCATO_5 As String, MERCATO_6 As String, MERCATO_7 As String, MERCATO_8 As String
    Public SQL As String, strSQL As String, strSQL1 As String
    Public IMPORTO1 As Long, IMPORTO2 As Long, IMPORTO3 As Long, IMPORTO4 As Long
    Public GIORNI As Long, IMPORTO_ACC As Double, IMPORTO_UTIL As Double
    Public CNSQL As ADODB.Connection
    Public CNSQL1 As ADODB.Connection
    Public RSSQL As ADODB.Recordset
    Public RSSQLD As ADODB.Recordset
    Public RSSQL1 As ADODB.Recordset
    Public RSSQL2 As ADODB.Recordset
    Public RSSQL3 As ADODB.Recordset
    Public RSSQL_LIST As ADODB.Recordset
    Public SERVERNAME As String, DATABASENAME As String, TABLENAME As String, USERIDSQL As String, PASSWORDSQL As String, TABLENAME1 As String
    Public sNodeParts() As String
    Public lvwItem As ListItem
    Public SFIND As String, TEST0() As String, TEST1 As String, TEST2 As String, TEST3 As String
    Public SQL1 As String
    Public APERTO_SCHEDA As String, APERTO_DATI As String, APERTO_DATE As String

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: connection lost... (6.0)

    That's fine, but it's not clear where the value is set.
    Anyway, I don't think you can open the recordsets just once.

  5. #5
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: connection lost... (6.0)

    ok...
    Now if i have understand..
    if i want make a SELECT from rset i must invoque this line for example:

    SSQL = "SELECT * FROM DATI WHERE PROVA1 = '" & MERCATO_1 & "'"
    RSSQL1.Open SSQL, CNSQL

    and when i close the user form or i want use the same rset for other code i must set nothing and close the rset just used?

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: connection lost... (6.0)

    You should always close a recordset and set it to Nothing when you don't need it any more.

    As long as a recordset is open, the table it is based on is in use.
    Until you set the recordset to Nothing, it takes up memory.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •