Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADO and FoxPro 2.6

Status
Not open for further replies.

tearaway

Programmer
Apr 6, 2001
2
US
Hello Team Fox,

I am, doing the following:

conFox.Open "Driver={Microsoft Visual FoxPro
Driver};SourceType=DBF;SourceDB=\\Plexusauto\c\PBSMWIN\LISTS\;Exclusive=No;O
LE DB Services =
0;BackgroundFetch=Yes;Collate=Machine;Null=Yes;Deleted=Yes;"

rsFox.Open "SELECT COUNT(*) FROM Binford.dbf WHERE PCN = " & vPCN,
conFox, adOpenForwardOnly, adLockReadOnly
'This works and I can use the following value
vRecCount = rsFox.Fields(0).Value
rsFox.Close

'Tride the following:
'conFox.close()
'conFox.Open

'Tried the following
'Set cmdFox = New ADODB.Command
'cmdFox.ActiveConnection = conFox
'cmdFox.CommandType = adCmdText
'cmdFox.CommandText = "use \\Plexusauto\c\PBSMWIN\LISTS\binford.dbf"

'This _does not work_ 'Syntax error or access violation. However, if I put
the same command in the FoxPro Command 'window, it works and I can APPEN
BLANK, etc. from there.
conFox.Execute "use \\Plexusauto\c\PBSMWIN\LISTS\binford.dbf", ,
adExecuteNoRecords

What am I doing wrong?

--

Tom Schulte
Application Developer
Plexus Systems
248-922-9690
 
Tom,
I'm afraid that ADO (a 32-bit technology) and FPW 2.6 (a 16-bit environment) aren't going to work together. Even if you switched to VFP 6.0, you're going to have to change the syntax a bit - what you are showing appears to be "pure" Visual Basic.

Rick
 
Hi Tom,

I assume that, in spite of having posted in the FoxPro 2.6 forum, you're actually using Visual FoxPro (for which there is also a forum :) :

I think the problem is that you are using trying to execute FoxPro commands against an ADO object.

To execute FoxPro commands you need to open a Visual FoxPro object through OLE:
Code:
appVFP= new VisualFoxPro.Application
appVFP.DoCmd("use \\Plexusauto\c\PBSMWIN\LISTS\binford.dbf")
fieldvalue= appVFP.Eval("fieldname")
? "fieldname= " & fieldvalue

What you are currently doing is creating an ADO object. Whilst the ADO object can access a FoxPro data source, it can't process FoxPro commands, in spite of having a command property.


 
Well, I am trying to write a componenet in VB to read daya from SQL 2000 (this works), read data from a FoxPro 2.6 free table (this works) and enter data into the same table (this does not work). Below is bascially what I have now. All the commands work fine in a VFP Command Window, However the INSERT command, or an APPEND variation starts a second component, OPEN which is modal. I think the VFP instance is looking for user feedback and that's what I am trying to stop so I can automate. Any advice? Other ways to interact with a 2.6 free table through COM? Thank you

Dim appVFP As FoxServer.FoxApplication
Set appVFP = New FoxServer.FoxApplication
appVFP.DoCmd ("SYS(2335 ,0)")
appVFP.DoCmd ("SET TALK OFF")

'late-binding also works
'Dim appVFP As Object
On Error Resume Next
'Set appVFP = CreateObject("Visualfoxpro.Application") 'appVFP = New VisualFoxPro.Application - THIS WON'T WORK
If Not IsObject(appVFP) Or Err.Number Then
SQL2SmartMailerErr ("appVFP failed to instantiate: " & Err.Description & " (" & Err.Number & ")")
Exit Function
End If

If IsObject(appVFP) Then
appVFP.DoCmd ("USE \\Plexusauto\c\PBSMWIN\LISTS\binford.dbf ALIAS BinfordList EXCLUSIVE")
Else 'Log Error
WriteLog ("appVFP not Object at USE")
Exit Function
End If

If IsObject(appVFP) Then
vSQL = "INSERT INTO BinfordList (PCN, INVOICE_NO, COMPANY, STREET, STREET2, CITY, STATE, ZIP, ZIP4) VALUES (" & vPCN & ", """ & rsSQL.Fields("Invoice_No").Value & """, """ & rsSQL.Fields("Company").Value & """, """ & rsSQL.Fields("Street").Value & """, """ & rsSQL.Fields("Street2").Value & """, """ & rsSQL.Fields("City").Value & """, """ & rsSQL.Fields("State").Value & """, """ & vZip & """, """ & vZip4 & """)"
appVFP.DoCmd (vSQL)
WriteLog (vSQL)
Else 'Log Error
SQL2SmartMailerErr ("appVFP not Object at INSERT")
Exit Function
End If


rsSQL.MoveNext
Loop
appVFP.DoCmd ("CLOSE TABLES")
appVFP.Quit
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top