Solved

SELECT WHERE with Foxpro Db from VB6

Posted on 1998-12-01
3
422 Views
Last Modified: 2013-12-25
I need to create a recordset such as the following:  SELECT * FROM Table1 WHERE Status = "OPEN"   ...but the "table" is a Foxpro .dbf.  I can access the file and use all the records, but I just want a subset.  SQL Server or Access wouldn't be a problem, but I can't seem to find the right method to use this filtering with an ISAM file.  

What's the best way to create a filtered recordset from a Foxpro 2.6 source?
0
Comment
Question by:gglover
3 Comments
 
LVL 3

Expert Comment

by:vbWhiz
ID: 1497925
How are you currently accessing the file and using the records? Are you using DAO? Some sample code would be a good start.
0
 
LVL 3

Accepted Solution

by:
cognition earned 50 total points
ID: 1497926
' I hope the following works for you !

    Dim wrkJet As Workspace
    Dim dbsTest As Database
    Dim rstTemp As Recordset

    ' Create Workspace
    Set wrkJet = CreateWorkspace("", "admin", "", dbUseJet)
   
    ' Open Database : Replace path to fox files and fox version
    Set dbsTest = wrkJet.OpenDatabase("o:\viglen data\dbfs\all", True, True, "FoxPro 2.5;")

    ' Create recordset with a select and a where clause
    ' Chaneg SQL to reflect your query
    ' If the filter is a text string then ensure that single quotes are used
    Set rstTemp = dbsTest.OpenRecordset("SELECT * FROM ordline WHERE ion = '393632'", dbOpenForwardOnly)
   
    ' Loop through recordset and print some results
    With rstTemp
        Do While Not .EOF
            Debug.Print .Fields(0), .Fields(1)
            .MoveNext
        Loop
    End With

    rstTemp.Close
    dbsTest.Close
    wrkJet.Close



0
 

Author Comment

by:gglover
ID: 1497927
That got me started - thanks!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now