Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Unable to ExecScript() COPY TO if data adapter not close
Message
De
12/02/2007 10:05:13
 
 
À
12/02/2007 10:01:24
Alexandre Palma
Harms Software, Inc.
Alverca, Portugal
Information générale
Forum:
ASP.NET
Catégorie:
Bases de données
Versions des environnements
Environment:
VB 8.0
OS:
Windows XP SP2
Database:
Visual FoxPro
Divers
Thread ID:
01189785
Message ID:
01194727
Vues:
11
>Michel in that case just do the IF USED check and also issue a SELECT table name to your code.

This issue was related to the fact that I had a global connection. As I mentioned a while ago, this has been resolved. Before doing the copy table process, I simply close the global connection and reopen it again as this level.

Here is the code:
    ' Do the backup of all tables
    Public Function Backup() As Boolean
        Dim lcDirectory As String = ""
        Dim lcTable As String = ""
        Dim lnCounter As Integer = 0
        Dim loDataProvider As Framework.Framework.Data = New Framework.Framework.Data(oApp)
        Dim loDataProviderBackup As Framework.Framework.Data = New Framework.Framework.Data(oApp)
        Dim loRow As DataRow

        oOriginator.Status.Text = "Backup..."

        ' Get the directory
        lcDirectory = oApp.GetIni(oApp.cINIDirectory + oApp.cINIFile, "System", "Backup")
        lcDirectory = oApp.GetPath(lcDirectory)

        ' Copy the files

        If Not loDataProvider.SQLExec("SELECT Table.Table FROM Table ORDER BY Table.Table") Then
            Return False
        End If

        ' This is necessary as the framework is using a global connection.
        ' As we have Task.dbf in operation at this level as well as Table.dbf just above, we need
        ' to close the connection before proceeding.
        oApp.aConnection(1, 2).Close()
        oApp.aConnection(1, 2).Open()

        For lnCounter = 0 To loDataProvider.nCount - 1
            loRow = loDataProvider.oDataSet.Tables("Temp").Rows(lnCounter)

            lcTable = Trim(loRow("Table"))

            oOriginator.Status.Text = "Copying " + lcTable + ".dbf " + _
             (lnCounter + 1).ToString + " of " + loDataProvider.nCount.ToString + "..."

            loDataProviderBackup.CommandTextAdd("EXECSCRIPT(""SET SAFETY OFF"")")
            loDataProviderBackup.CommandTextAdd("EXECSCRIPT(""SET EXCLUSIVE OFF"")")
            loDataProviderBackup.CommandTextAdd("EXECSCRIPT(""USE " + lcTable + """)")
            loDataProviderBackup.CommandTextAdd("EXECSCRIPT(""COPY TO '" + lcDirectory + lcTable + "'"")")
            loDataProviderBackup.CommandTextAdd("EXECSCRIPT(""USE"")")

            ' Index
            If Not loDataProviderBackup.ExecuteNonQuery() Then
                Return False
            End If

        Next

        Return True
    End Function
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform