BChernick
Fri Apr 25 12:38:00 CDT 2008
Thanks to both you and S. Wuebbe for the interesting background material but
I'm wondering if this might be overkill. (Since I'm never dealing with more
than one table at a time.)
As of right now both my local machine and the server now have the latest
version OleDB driver and nothing's changed. It runs fine on mine and fails
on the server. (Only the Pack command. Everything else runs normally.) The
same error: Command contains unrecognized phrase/keyword.
It occured to me that, given the nature of connections from Web apps, I
should try combining the Use Exclusive and Pack commands into one
string/ExecuteNonQuery.
So I did this:
Dim dcc As New OleDb.OleDbCommand("Use <path>.<filename>.dbf
Exclusive;Pack TableName", dc)
and got the same results, runs fine on my machine, crashes on the server
with the same error: "Command contains unrecognized phrase/keyword."
"Rush Strong" wrote:
> FoxPro opens each table in a separate "work area." Each Work Area is
> numbered. Only one work area is 'current;' commands affect the table in
> the current area by default - but other areas can be specified.
> Consider the following:
>
> SELECT 1
> USE FirstTable.dbf
>
> SELECT 2
> USE SecondTable
>
> SELECT 3
> USE MyForm.scx
>
> USE OneMoreTable IN 4 ALIAS LastTable
>
> FirstTable.dbf is open in WA (work area) 1. [Specifying the '.dbf' in
> the table name is optional, if the table is named with the default 'dbf'
> extension.]
>
> SecondTable is open in WA2. The 'dbf' extension was left off, as is
> typically the case.
>
> WA3 is a bit different. MyForm.scx is a table which describes a form.
> It is identical (in structure) to a .dbf table, only the extension has
> been changed. Because it is a non-default extension, the 'scx' must be
> specified.
>
> The final command opens OneMoreTable in WA4, but does NOT select that
> area - we're still in WA3. This shows the basic IN syntax - it allows
> commands to affect a non-current WA. We've also added the ALIAS clause,
> which effectively renames 'OneMoreTable' to 'LastTable.' (This only
> affects code references - the actual file name, OneMoreTable.dbf, is
> unchanged.)
>
> Issuing a USE command without a table name will close any table in the
> current area. The USE command can also be qualified with the IN
> clause. Thus,
>
> SELECT 1
> USE
>
> will close FirstTable, leaving us in an empty WA.
>
> USE IN 2
>
> will close SecondTable. We're still in WA1; both WA1 and WA2 are empty.
>
> Back in the old days, we had to keep track of which table was open in
> which WA number. This was simplified by the use of ALIASes. Each table
> is assigned an alias, which defaults to the file name (without
> extension). Thus, we could have closed the above tables by:
>
> SELECT FirstTable
> USE
>
> USE IN SecondTable
>
> [While Fox still supports the use of WA numbers, it is obviously much
> clearer to use aliases.]
>
> We can now close the last two tables:
>
> USE IN C
> USE IN LastTable
>
> Huh? Where did the 'C' come from? Well, believe it or not, their is a
> third way to reference work areas - the first half a dozen are also
> lettered A through F. This is a holdover from the early days, when we
> only had 6 areas to work with. That limit has gone up a couple of times,
> to (IIRC) 64K currently. USE IN C is the same as USE IN 3 which (in
> this case) is the same as USE IN MyForm (the alias of 'MyForm.scx').
>
> And so to answer your question: USE IN [Alias|WA number|WA letter]
> closes a single table in the specified work area.
>
> Hope it helps...
>
> - Rush
>
> B. Chernick wrote:
> > I'm sorry but you've completely lost me. 'Use In' is a close command?
> >
> > (I'm also currently looking at FoxPro 6's help and that doesn't help much
> > either. If I may quote: 'Specifies the work area in which the table is
> > opened. You can close a table in a specific work area by issuing USE with the
> > IN clause and the work area number.' I really don't understand what this
> > is saying.)
> >
> > "Rush Strong" wrote:
> >
> >
> >> USE IN TableName
> >>
> >> is the "specifically FoxPro command" for closing TableName, regardless
> >> of which work area it's in.
> >>
> >> - Rush
> >>
> >> B. Chernick wrote:
> >>
> >>> I do an Open, Use TableName, a Pack TableName, and then a Close in the
> >>> Finally clause (so it always gets called).
> >>>
> >>> (I don't recognize this 'Use In' you refer to. What is that?)
> >>>
> >>> It occurs to me that the Close I am referring to is the Close of the OleDB
> >>> connection object . Are you saying that I need some other specifically
> >>> FoxPro command to close the table before I close the connection?
> >>>
> >>> "swdev2" wrote:
> >>>
> >>>
> >>>
> >>>> A pack takes exclusive control of a table.
> >>>> If you don't CLOSE the table after packing it, ie - you still have it open,
> >>>> then NO ONE ELSE can get to it for any 'exclusive' file i/o.
> >>>>
> >>>> I'd check that you're actually CLOSING the file after the pack.
> >>>> "PACK Tablename", right ?
> >>>> then
> >>>> "Use in (Tablename) "
> >>>>
> >>>> It's not enough just to destroy the data connector by 'exiting' the
> >>>> program - it will hang around in the server memory after it was 'destroyed'
> >>>> for a bit.
> >>>>
> >>>> HTH !
> >>>> Mondo Regards [Bill]
> >>>> --
> >>>> ===================
> >>>> William Sanders / EFG VFP / mySql / MS-SQL
> >>>> www.efgroup.net/vfpwebhosting
> >>>> www.terrafox.net www.viasqlserver.net
> >>>>
> >>>> "B. Chernick" <BChernick@discussions.microsoft.com> wrote in message
> >>>> news:AA92E00B-91D1-49FF-8B69-4B1E1414E24D@microsoft.com...
> >>>>
> >>>>
> >>>>> I may have spoken too soon. The program works fine on my local machine.
> >>>>>
> >>>>>
> >>>> If
> >>>>
> >>>>
> >>>>> I run it on our web server, it crashes with the message: 'Command contains
> >>>>> unrecognized phrase/keyword.'
> >>>>>
> >>>>> This may be premature. I'm told that the users on that server are now
> >>>>> having permission problems, unable to read/write to the tables through
> >>>>>
> >>>>>
> >>>> this
> >>>>
> >>>>
> >>>>> app, or something like that, and I'm going to wait for that to be fixed.
> >>>>>
> >>>>>
> >>>> But
> >>>>
> >>>>
> >>>>> could this cause a problem like that?
> >>>>>
> >>>>> Or is this a more likely possibility?:
> >>>>>
> >>>>>
> >>>>
http://support.microsoft.com/kb/932201
> >>>>
> >>>>
> >>>>> "Anders Altberg" wrote:
> >>>>>
> >>>>>
> >>>>>
> >>>>>> dcc.CommandText = "PACK Tablename"
> >>>>>>
> >>>>>> -Anders
> >>>>>>
> >>>>>> "B. Chernick" <BChernick@discussions.microsoft.com> wrote in message
> >>>>>> news:DD5D2842-752F-4845-B048-0CF60EA3A0F5@microsoft.com...
> >>>>>>
> >>>>>>
> >>>>>>> We have a temporary Dot Net 2.0 web app that connects to some FoxPro 6
> >>>>>>>
> >>>>>>>
> >>>> DBF
> >>>>
> >>>>
> >>>>>>> tables. I've been asked to enhance it. All I am trying to do is put
> >>>>>>>
> >>>>>>>
> >>>> a
> >>>>
> >>>>
> >>>>>>> button on the main page to run a Pack command. So far no luck. I
> >>>>>>>
> >>>>>>>
> >>>> admit
> >>>>
> >>>>
> >>>>>>> that
> >>>>>>> I have not done much with direct ado.net connections lately. This is
> >>>>>>> basically the code.
> >>>>>>>
> >>>>>>> Dim dc As New OleDb.OleDbConnection(<same connection string used in
> >>>>>>>
> >>>>>>>
> >>>> the
> >>>>
> >>>>
> >>>>>>> rest of the app>)
> >>>>>>> dc.Open()
> >>>>>>> Dim dcc As New OleDb.OleDbCommand("Use <Filename.dbf> Exclusive", dc)
> >>>>>>> dcc.ExecuteNonQuery
> >>>>>>> dcc.CommandText = "Pack" <