Solved

SELECT WHERE with Foxpro Db from VB6

Posted on 1998-12-01
3
426 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Excel - Save a copy of work book 13 91
VB6 - Convert HH:MM into Decimal 8 70
Spell Check in VB6 13 137
clicking a shape in a frame array vb6 3 48
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

726 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