Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Set date format to VFPOLEDB
Message
 
 
À
14/09/2009 10:08:41
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 SP2
OS:
Vista
Network:
Windows 2003 Server
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01424074
Message ID:
01424127
Vues:
71
You're welcome, glad to help.

I always suggest to use parameters over string concatenation. It produces safer code.

>>Can you use parameters instead? Or use the format Boris suggested.
>
>Yes, Naomi - I thing that the best solution is use parameters like the code below.
>
>Thinks so much
>
>
>Local loConn as "ADODB.Connection", loCmd as "ADODB.Command"
>Local loParameter0 as "ADODB.Parameter", loParameter1 as "ADODB.Parameter", loRs as ADODB.Recordset
>* create and oppen ADODB.Connection
>loConn = NewObject("ADODB.Connection")
>loConn.ConnectionString = "Provider=VFPOLEDB.1;Data Source='Base\Scd4.dbc';Password='';Collating Sequence=MACHINE"
>loConn.Open()
>* create and configure ADODB.Command
>loCmd = NewObject("ADODB.Command")
>loCmd.ActiveConnection = loConn
>loCmd.CommandText = "Select * from Distr where (dis_data >= ? and dis_data <= ?)"
>* create parameters and add it to ADODB.Command
>loParameter0 = loCmd.CreateParameter("pDateIni", 133, 1, 8, this.txtDateIni.Value)
>loParameter1 = loCmd.CreateParameter("pDateFin", 133, 1, 8, this.txtDateFin.Value)
>loCmd.Parameters.Append(loParameter0)
>loCmd.Parameters.Append(loParameter1)
>* create and fill ADODB.RecordSet
>loRs = NewObject("ADODB.RecordSet")
>loRs.Open(loCmd, , 1) && loRs.CursorType = 1  && adOpenKeyset see "RecordSet types" in http://msdn2.microsoft.com/en-us/library/ms917355.aspx
>* check the RecordCount
>?loRs.RecordCount
>* close ADODB.Connection
>loConn.Close()
>
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform