Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Unable to get random generation with OleDb
Message
De
18/09/2006 11:43:52
 
 
À
18/09/2006 11:16:22
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Database:
Visual FoxPro
Divers
Thread ID:
01154512
Message ID:
01154736
Vues:
14
Hi,

>>Since the connection is open when the .Fill is called the dataadapter will leave the connection open and you will need to close it yourself afterwards
>
>Ok, this works. So, this means, if I have a robot that does those record selections every minute, I will have to issue the RAND(-1) everytime just before the SQL command in the same environment.

Essentially Yes - you will need to set up the environment when creating the connection. One option would be to make the query a SP and issue the RAND(-1) there. I usually open the connection in a method so I can consistently set the environment. Something like:
Private Shared Function OpenVFPConnection() As IDbConnection

        Dim VFPData = New System.Data.OleDb.OleDbConnection
        VFPData.ConnectionString = "whatever"

        Try
            VFPData.Open()
        Catch ex As Exception
            Throw New Exception("Failed to open Data Connectionn", ex)
        End Try

        'Set VFP environment bits:
        Dim oledbcmd As New OleDbCommand
        oledbcmd.Connection = VFPData
        oledbcmd.CommandText = "SET NULL OFF" + Chr(13) + Chr(10) + "SET DELETE ON" +CHR(13)+CHR(10)+"RAND(-1)"
        oledbcmd.CommandType = CommandType.Text
        oledbcmd.ExecuteNonQuery()
        Return CType(VFPData, IDbConnection)
    End Function
Then always use
.Command.Connection = OpenVFPConnection()
.etc
HTH,
Viv
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform