Re: OLE DB from .NET/open & close connections
- From: "Marc Miller" <ctefsd_sys@xxxxxxxxxxx>
- Date: Fri, 8 Dec 2006 16:02:25 -0500
Bernhard,
Firstly, thank you.
The 'oCmd.CommandText = "SELECT tableTwo"' threw an exception of "No table
is open
in the current workarea" (curious!). But the 'oCmd.CommandText = "PACK IN
tableTwo"'
did the trick.
Without people like you my life would be constant confusion.
Thanks again,
Marc
"Bernhard Sander" <fuchs@xxxxxxx> wrote in message
news:uGrSQ$vGHHA.924@xxxxxxxxxxxxxxxxxxxxxxx
Hi Marc,
I've started working with FoxPro tables from VB.NET and I found that whenJust a guess:
deleting and packing
two tables in succession, I have to close and then re-open the
connection, otherwise the second
pack statement doesn't execute and 'tableTwo' is still populated with the
deleted records.
Is there a better way, or is this just necessary due to the behavior?
Basically this is what I am doing:
oConn.open()
oCmd.CommandText = "DELETE FROM tableOne WHERE key = 10"
oCmd.ExecuteNonQuery()
oCmd.CommandText = "PACK"
oCmd.ExecuteNonQuery()
oConn.close()
oConn.open()
oCmd.CommandText = "DELETE FROM tableTwo"
oCmd.ExecuteNonQuery()
oCmd.CommandText = "PACK"
oCmd.ExecuteNonQuery()
oConn.close()
after the DELETE FROM tabelTwo and before the PACK, maybe add this:
oCmd.CommandText = "DELETE FROM tableTwo"
oCmd.ExecuteNonQuery()
oCmd.CommandText = "SELECT tableTwo"
oCmd.ExecuteNonQuery()
oCmd.CommandText = "PACK"
...
Background: Foxpro uses some a workspace for every table it opens. One of
these workspaces is the "active workspace". A SQL command opens the
necessary tables in unused workspaces. It seems, when foxpro opens the
first table in a session, it opens the table in the active workspace. The
next table(s) are opened in other free workspaces, but these workspaces
don't become active. You can select the active workspace with the
mentioned SELECT command. This syntax is not SQL syntax but foxpro syntax.
Another way to pack the second table would be:
oCmd.CommandText = "PACK IN tableTwo"
With this command you tell foxpro to pack the table of a different
workspace than the active workspace.
Regards
Bernhard Sander
.
- References:
- OLE DB from .NET/open & close connections
- From: Marc Miller
- Re: OLE DB from .NET/open & close connections
- From: Bernhard Sander
- OLE DB from .NET/open & close connections
- Prev by Date: Re: Shellexecute...
- Next by Date: Re: VFP 9/SQL Training?
- Previous by thread: Re: OLE DB from .NET/open & close connections
- Next by thread: Re: OLE DB from .NET/open & close connections
- Index(es):
Relevant Pages
|