Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Set date format to VFPOLEDB
Message
From
14/09/2009 10:08:41
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Vista
Network:
Windows 2003 Server
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01424074
Message ID:
01424122
Views:
75
>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()
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform