Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

VFPOLEDB select deleted records

Posted on 2007-11-19
5
Medium Priority
?
1,556 Views
Last Modified: 2008-02-01
Experts
I am using the VFPOLDB driver to connect to fox pro tables, to my understanding by default when running a select statement it will not return deleted records, how do you change this setting?  Is there something in the connection string that needs to be changed?
Thanks!
0
Comment
Question by:SZachmann
[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
  • 2
5 Comments
 
LVL 53

Expert Comment

by:Dhaest
ID: 20372401
How can you return deleted records ?
Do those records have a special status ?
0
 
LVL 2

Author Comment

by:SZachmann
ID: 20373318
Dhaest,

Yes, in Foxpro "deleted" records are really just records that are marked for deletion meaning that they will be permanently deleted next time the "PACK" command is run on that table.  If you were to look at the raw records in VFP 8.0 for instance, you would see the records however there would be a small black mark next to the ones that are marked for deletion.  These are the records that the VFPOLEDB driver does not seem to return.
0
 
LVL 53

Accepted Solution

by:
Dhaest earned 2000 total points
ID: 20373363
Here's some example VB code to work with the deleted status of a row:

Source: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1566422&SiteID=1
  Try
 
   Dim cn1 As New OleDbConnection( _
    "Provider=VFPOLEDB.1;Data Source=C:\Temp\;")
   cn1.Open()
   '-- Make some VFP data to play with
   Dim cmd1 As New OleDbCommand( _
    "Create Table TestDBF (Field1 I, Field2 C(10))", cn1)
   Dim cmd2 As New OleDbCommand( _
    "Insert Into TestDBF Values (1, 'Hello')", cn1)
   Dim cmd3 As New OleDbCommand( _
    "Insert Into TestDBF Values (2, 'World')", cn1)
   Dim cmd4 As New OleDbCommand( _
    "Delete From TestDBF Where Field1 = 1", cn1)
   cmd1.ExecuteNonQuery()
   cmd2.ExecuteNonQuery()
   cmd3.ExecuteNonQuery()
   cmd4.ExecuteNonQuery()
   cn1.Close()
 
   Dim cn2 As New OleDbConnection( _
    "Provider=VFPOLEDB.1;Data Source=C:\Temp\;")
   cn2.Open()
 
   Dim cmd5 As New OleDbCommand( _
    "Select * From TestDBF", cn2)
   Dim da1 As New OleDbDataAdapter(cmd5)
   Dim ds1 As New DataSet
   Dim dr1 As DataRow
   da1.Fill(ds1)
   For Each dr1 In ds1.Tables(0).Rows
    Console.WriteLine( _
     dr1.Item(0).ToString() & ", " & dr1.Item(1).ToString)
   Next
   Console.ReadLine()
   cn2.Close()
 
   Dim cn3 As New OleDbConnection( _
    "Provider=VFPOLEDB.1;Data Source=C:\Temp\;")
   cn3.Open()
 
   Dim cmd6 As New OleDbCommand( _
    "Set Deleted Off", cn3)
   cmd6.ExecuteNonQuery()
   Dim cmd7 As New OleDbCommand( _
      "Select Deleted('TestDBF') As IsDeleted, TestDBF.* From TestDBF", cn3)
   Dim da2 As New OleDbDataAdapter(cmd7)
   Dim ds2 As New DataSet
   Dim dr2 As DataRow
   da2.Fill(ds2)
   For Each dr2 In ds2.Tables(0).Rows
    Console.WriteLine( _
    dr2.Item(0).ToString() & ", " & dr2.Item(1).ToString() & ", " & dr2.Item(2).ToString())
   Next
   Console.ReadLine()
   cn2.Close()
 
  Catch e As Exception
   MsgBox(e.ToString())
  End Try

Open in new window

0
 
LVL 2

Author Comment

by:SZachmann
ID: 20373417
I see, so basically you're opening your connection and executing several commands, each defined as a separate oledbcommand object.  I'm really wasn't familiar with doing that as I typically just expect to connect to a DB, run a single command (usually a select) and get my data.  I'll give that a try and let you know if it works, but it makes sense to me seeing the code.
0
 
LVL 2

Author Comment

by:SZachmann
ID: 20373571
I tested the code you sent and it worked perfectly.  Thanks for the help!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

730 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