Search code examples
visual-foxprofoxpro

Select Visual FoxPro Search a dbf meanwhile is connected to an sql database


In a simple program where i connect from visual foxpro to a sql server with the connectionstring and i have already controlled if is connected successfully when i create a simple select command with the name of the table from the database the program try to search the table in local and expect me to give him a dbf file meanwhile the table is in the database in sql

Select * FROM table Where column=k into cursor nnn

Solution

  • Your question is not clear. That piece of code you supplied is just a query done against a VFP table\cursor in your local. It has nothing to do with an SQL server query. Here is a sample doing an SQL server query using sample Northwind database:

    LOCAL lnHandle, lcCountry
    lnHandle = SQLSTRINGCONNECT("Driver={SQL Server Native Client 11.0};Server=.;Database=Northwind;Trusted_Connection=yes")
    
    lcCountry = "USA"
    SQLEXEC(m.lnHandle, "Select * from Customers where Country = ?m.lcCountry", "crsCustomers")
    
    SQLDISCONNECT(m.lnHandle)
    
    SELECT crsCustomers
    browse
    

    This is an SPT query. There is also CursorAdapter, in which you could use ODBC or OLEDB.

    Please explain what you are really asking if that wasn't what you meant.