Packing a Table from VB 
Author Message
 Packing a Table from VB

After marking the records in a FoxPro table for deletion from VB 6.0, I'm
attempting to issue a "pack" command, but am not quite sure how to do it.
Does anyone know?


Sun, 04 Sep 2005 15:18:51 GMT  
 Packing a Table from VB
Hello, Curt!
You wrote  on Wed, 19 Mar 2003 02:18:51 -0500:

 CE> After marking the records in a FoxPro table for deletion from VB 6.0,
 CE> I'm attempting to issue a "pack" command, but am not quite sure how to
 CE> do it. Does anyone know?

This was posted in this NG on 03-12-2003:

Anders Altberg:
Exec("PACK tablename")
Tablename has to be opened exclusive.

Cindy Winegarden:
http://support.microsoft.com/default.aspx?scid=kb;en-us;234756
---
Eric den Doop
www.foxite.com - The Home Of The Visual FoxPro Experts - Powered By VFP8



Sun, 04 Sep 2005 16:01:43 GMT  
 Packing a Table from VB
Hi Curt,

Eric posted two references on how to do it. I'd like to point out that PACK
requires exclusive use of the tables, and is not something you can do every
time you delete a record in a production situation. PACKing tables, if done
at all, is usually part of weekly or monthly "housekeeping" and done after
hours.

Also, there's usually no need to PACK tables since the deleted records are
filtered out by default. Usually developers who ask questions about PACKing
tables have one of two situations: they have really large tables and lots of
deleted records and want to "recycle" the deleted records (not sure how you
would do this in VB) or they want to re-use primary keys, which is not a
good idea in a relational database.

--
Cindy Winegarden  MCSD, Microsoft Visual FoxPro MVP

http://msdn.microsoft.com/vfoxpro  http://foxcentral.net


Quote:
> After marking the records in a FoxPro table for deletion from VB 6.0, I'm
> attempting to issue a "pack" command, but am not quite sure how to do it.
> Does anyone know?



Sun, 04 Sep 2005 22:17:26 GMT  
 Packing a Table from VB
Thanks!


Quote:
> Hi Curt,

> Eric posted two references on how to do it. I'd like to point out that
PACK
> requires exclusive use of the tables, and is not something you can do
every
> time you delete a record in a production situation. PACKing tables, if
done
> at all, is usually part of weekly or monthly "housekeeping" and done after
> hours.

> Also, there's usually no need to PACK tables since the deleted records are
> filtered out by default. Usually developers who ask questions about
PACKing
> tables have one of two situations: they have really large tables and lots
of
> deleted records and want to "recycle" the deleted records (not sure how
you
> would do this in VB) or they want to re-use primary keys, which is not a
> good idea in a relational database.

> --
> Cindy Winegarden  MCSD, Microsoft Visual FoxPro MVP

> http://msdn.microsoft.com/vfoxpro  http://foxcentral.net



> > After marking the records in a FoxPro table for deletion from VB 6.0,
I'm
> > attempting to issue a "pack" command, but am not quite sure how to do
it.
> > Does anyone know?



Sun, 04 Sep 2005 23:32:07 GMT  
 Packing a Table from VB
I only see one reference from Eric in this newsgroup


Quote:
> Hi Curt,

> Eric posted two references on how to do it. I'd like to point out that
PACK
> requires exclusive use of the tables, and is not something you can do
every
> time you delete a record in a production situation. PACKing tables, if
done
> at all, is usually part of weekly or monthly "housekeeping" and done after
> hours.

> Also, there's usually no need to PACK tables since the deleted records are
> filtered out by default. Usually developers who ask questions about
PACKing
> tables have one of two situations: they have really large tables and lots
of
> deleted records and want to "recycle" the deleted records (not sure how
you
> would do this in VB) or they want to re-use primary keys, which is not a
> good idea in a relational database.

> --
> Cindy Winegarden  MCSD, Microsoft Visual FoxPro MVP

> http://msdn.microsoft.com/vfoxpro  http://foxcentral.net



> > After marking the records in a FoxPro table for deletion from VB 6.0,
I'm
> > attempting to issue a "pack" command, but am not quite sure how to do
it.
> > Does anyone know?



Sun, 04 Sep 2005 23:49:43 GMT  
 Packing a Table from VB
When I issue this command as

Connection.Execute("PACK Employees")

I'm told the file is already in use.  So I try to issue


Quote:
> Hi Curt,

> Eric posted two references on how to do it. I'd like to point out that
PACK
> requires exclusive use of the tables, and is not something you can do
every
> time you delete a record in a production situation. PACKing tables, if
done
> at all, is usually part of weekly or monthly "housekeeping" and done after
> hours.

> Also, there's usually no need to PACK tables since the deleted records are
> filtered out by default. Usually developers who ask questions about
PACKing
> tables have one of two situations: they have really large tables and lots
of
> deleted records and want to "recycle" the deleted records (not sure how
you
> would do this in VB) or they want to re-use primary keys, which is not a
> good idea in a relational database.

> --
> Cindy Winegarden  MCSD, Microsoft Visual FoxPro MVP

> http://msdn.microsoft.com/vfoxpro  http://foxcentral.net



> > After marking the records in a FoxPro table for deletion from VB 6.0,
I'm
> > attempting to issue a "pack" command, but am not quite sure how to do
it.
> > Does anyone know?



Sun, 04 Sep 2005 23:51:05 GMT  
 Packing a Table from VB
I'm assuming that the .Execute method on an ADO Connection object can be
used to send any FoxPro message.  Because my table is "in use" when I try to
PACK it, I'm trying to send "CLOSE DATABASES" to close it first.

When I do this, I get the error,

Run-time error '-2147217911 (80040e09)

[Microsoft][OCBC Visual FoxPro Driver]Syntax error or access violation.

These commands work in the FoxPro command window.  The connection string I'm
using is as follows:

Driver={Microsoft Visual FoxPro Driver};SourceType=DBC;" & _
           "SourceDB=c:\JFLTime\data\JFLTime.dbc;" & _
           "Exclusive=Yes;"

What's my next step?


Quote:
> Hi Curt,

> Eric posted two references on how to do it. I'd like to point out that
PACK
> requires exclusive use of the tables, and is not something you can do
every
> time you delete a record in a production situation. PACKing tables, if
done
> at all, is usually part of weekly or monthly "housekeeping" and done after
> hours.

> Also, there's usually no need to PACK tables since the deleted records are
> filtered out by default. Usually developers who ask questions about
PACKing
> tables have one of two situations: they have really large tables and lots
of
> deleted records and want to "recycle" the deleted records (not sure how
you
> would do this in VB) or they want to re-use primary keys, which is not a
> good idea in a relational database.

> --
> Cindy Winegarden  MCSD, Microsoft Visual FoxPro MVP

> http://msdn.microsoft.com/vfoxpro  http://foxcentral.net



> > After marking the records in a FoxPro table for deletion from VB 6.0,
I'm
> > attempting to issue a "pack" command, but am not quite sure how to do
it.
> > Does anyone know?



Sun, 04 Sep 2005 23:56:25 GMT  
 Packing a Table from VB
I'm looking for more posts on the subject, but I don't see any.

When I send "PACK" to the database as Eric described, I get the error that
the table is in use.  Assuming that I can send


Quote:
> Hi Curt,

> Eric posted two references on how to do it. I'd like to point out that
PACK
> requires exclusive use of the tables, and is not something you can do
every
> time you delete a record in a production situation. PACKing tables, if
done
> at all, is usually part of weekly or monthly "housekeeping" and done after
> hours.

> Also, there's usually no need to PACK tables since the deleted records are
> filtered out by default. Usually developers who ask questions about
PACKing
> tables have one of two situations: they have really large tables and lots
of
> deleted records and want to "recycle" the deleted records (not sure how
you
> would do this in VB) or they want to re-use primary keys, which is not a
> good idea in a relational database.

> --
> Cindy Winegarden  MCSD, Microsoft Visual FoxPro MVP

> http://msdn.microsoft.com/vfoxpro  http://foxcentral.net



> > After marking the records in a FoxPro table for deletion from VB 6.0,
I'm
> > attempting to issue a "pack" command, but am not quite sure how to do
it.
> > Does anyone know?



Mon, 05 Sep 2005 00:47:03 GMT  
 Packing a Table from VB
Then try Conn.execute ("set exclusive on;pack tabelname")
-Anders

There a KB aerticle Q234756 "How to pack a table throght the Visual FxoPro
ODBC driver"
Here's some sample VC++ code
#include <afxdb.h>
#include <iostream.h>

void main()
{
  try
  {
  CDatabase db;
  db.OpenEx("driver=Microsoft Visual FoxPro
Driver;sourcetype=dbc;sourcedb=C:\\Q234756_TEST\\test.dbc;exclusive=yes");
  db.ExecuteSQL("set exclusive on;pack t1");
  cout << "Table Packed!" <<endl;
  db.Close();
  }
  catch(CDBException *E)
  {
   cout << E->m_strError <<endl;
  }

Quote:
}



Quote:
> I'm assuming that the .Execute method on an ADO Connection object can be
> used to send any FoxPro message.  Because my table is "in use" when I try
to
> PACK it, I'm trying to send "CLOSE DATABASES" to close it first.

> When I do this, I get the error,

> Run-time error '-2147217911 (80040e09)

> [Microsoft][OCBC Visual FoxPro Driver]Syntax error or access violation.

> These commands work in the FoxPro command window.  The connection string
I'm
> using is as follows:

> Driver={Microsoft Visual FoxPro Driver};SourceType=DBC;" & _
>            "SourceDB=c:\JFLTime\data\JFLTime.dbc;" & _
>            "Exclusive=Yes;"

> What's my next step?



> > Hi Curt,

> > Eric posted two references on how to do it. I'd like to point out that
> PACK
> > requires exclusive use of the tables, and is not something you can do
> every
> > time you delete a record in a production situation. PACKing tables, if
> done
> > at all, is usually part of weekly or monthly "housekeeping" and done
after
> > hours.

> > Also, there's usually no need to PACK tables since the deleted records
are
> > filtered out by default. Usually developers who ask questions about
> PACKing
> > tables have one of two situations: they have really large tables and
lots
> of
> > deleted records and want to "recycle" the deleted records (not sure how
> you
> > would do this in VB) or they want to re-use primary keys, which is not a
> > good idea in a relational database.

> > --
> > Cindy Winegarden  MCSD, Microsoft Visual FoxPro MVP

> > http://msdn.microsoft.com/vfoxpro  http://foxcentral.net



> > > After marking the records in a FoxPro table for deletion from VB 6.0,
> I'm
> > > attempting to issue a "pack" command, but am not quite sure how to do
> it.
> > > Does anyone know?



Mon, 05 Sep 2005 00:55:19 GMT  
 Packing a Table from VB
Anders,

I'm still getting "file is in use".  When I try to issue a "CLOSE DATABASES"
comand right before the line

Connection.Execute("SET EXCLUSIVE ON;PACK Employees")

I get the error a syntax error.  Thanks for your feedback.


Quote:
> Then try Conn.execute ("set exclusive on;pack tabelname")
> -Anders

> There a KB aerticle Q234756 "How to pack a table throght the Visual FxoPro
> ODBC driver"
> Here's some sample VC++ code
> #include <afxdb.h>
> #include <iostream.h>

> void main()
> {
>   try
>   {
>   CDatabase db;
>   db.OpenEx("driver=Microsoft Visual FoxPro
> Driver;sourcetype=dbc;sourcedb=C:\\Q234756_TEST\\test.dbc;exclusive=yes");
>   db.ExecuteSQL("set exclusive on;pack t1");
>   cout << "Table Packed!" <<endl;
>   db.Close();
>   }
>   catch(CDBException *E)
>   {
>    cout << E->m_strError <<endl;
>   }
> }


> > I'm assuming that the .Execute method on an ADO Connection object can be
> > used to send any FoxPro message.  Because my table is "in use" when I
try
> to
> > PACK it, I'm trying to send "CLOSE DATABASES" to close it first.

> > When I do this, I get the error,

> > Run-time error '-2147217911 (80040e09)

> > [Microsoft][OCBC Visual FoxPro Driver]Syntax error or access violation.

> > These commands work in the FoxPro command window.  The connection string
> I'm
> > using is as follows:

> > Driver={Microsoft Visual FoxPro Driver};SourceType=DBC;" & _
> >            "SourceDB=c:\JFLTime\data\JFLTime.dbc;" & _
> >            "Exclusive=Yes;"

> > What's my next step?



> > > Hi Curt,

> > > Eric posted two references on how to do it. I'd like to point out that
> > PACK
> > > requires exclusive use of the tables, and is not something you can do
> > every
> > > time you delete a record in a production situation. PACKing tables, if
> > done
> > > at all, is usually part of weekly or monthly "housekeeping" and done
> after
> > > hours.

> > > Also, there's usually no need to PACK tables since the deleted records
> are
> > > filtered out by default. Usually developers who ask questions about
> > PACKing
> > > tables have one of two situations: they have really large tables and
> lots
> > of
> > > deleted records and want to "recycle" the deleted records (not sure
how
> > you
> > > would do this in VB) or they want to re-use primary keys, which is not
a
> > > good idea in a relational database.

> > > --
> > > Cindy Winegarden  MCSD, Microsoft Visual FoxPro MVP

> > > http://msdn.microsoft.com/vfoxpro  http://foxcentral.net



> > > > After marking the records in a FoxPro table for deletion from VB
6.0,
> > I'm
> > > > attempting to issue a "pack" command, but am not quite sure how to
do
> > it.
> > > > Does anyone know?



Mon, 05 Sep 2005 01:18:06 GMT  
 Packing a Table from VB
Hi
I tried this from inside VFP but it should work with some changes in VB
oconn = NEWOBJECT('adodb.connection')
connstrx=[Driver=Microsoft Visual FoxPro Driver;SourceType=DBC;] + ;
           "SourceDB=d:\projects\tests\testdata.dbc;" + ;
           "Exclusive=Yes;"
oconn.connectionstring=connstrx
oconn.Open(oconn.ConnectionString)
oconn.Execute("pack phonetypes")

I had a terrible lot of problems till it dawned on me that the 'Not a table'
messages occured with VFP8 tables with an AutoInc column.
-Anders


Quote:
> Anders,

> I'm still getting "file is in use".  When I try to issue a "CLOSE
DATABASES"
> comand right before the line

> Connection.Execute("SET EXCLUSIVE ON;PACK Employees")

> I get the error a syntax error.  Thanks for your feedback.



> > Then try Conn.execute ("set exclusive on;pack tabelname")
> > -Anders

> > There a KB aerticle Q234756 "How to pack a table throght the Visual
FxoPro
> > ODBC driver"
> > Here's some sample VC++ code
> > #include <afxdb.h>
> > #include <iostream.h>

> > void main()
> > {
> >   try
> >   {
> >   CDatabase db;
> >   db.OpenEx("driver=Microsoft Visual FoxPro

Driver;sourcetype=dbc;sourcedb=C:\\Q234756_TEST\\test.dbc;exclusive=yes");

- Show quoted text -

Quote:
> >   db.ExecuteSQL("set exclusive on;pack t1");
> >   cout << "Table Packed!" <<endl;
> >   db.Close();
> >   }
> >   catch(CDBException *E)
> >   {
> >    cout << E->m_strError <<endl;
> >   }
> > }


> > > I'm assuming that the .Execute method on an ADO Connection object can
be
> > > used to send any FoxPro message.  Because my table is "in use" when I
> try
> > to
> > > PACK it, I'm trying to send "CLOSE DATABASES" to close it first.

> > > When I do this, I get the error,

> > > Run-time error '-2147217911 (80040e09)

> > > [Microsoft][OCBC Visual FoxPro Driver]Syntax error or access
violation.

> > > These commands work in the FoxPro command window.  The connection
string
> > I'm
> > > using is as follows:

> > > Driver={Microsoft Visual FoxPro Driver};SourceType=DBC;" & _
> > >            "SourceDB=c:\JFLTime\data\JFLTime.dbc;" & _
> > >            "Exclusive=Yes;"

> > > What's my next step?



> > > > Hi Curt,

> > > > Eric posted two references on how to do it. I'd like to point out
that
> > > PACK
> > > > requires exclusive use of the tables, and is not something you can
do
> > > every
> > > > time you delete a record in a production situation. PACKing tables,
if
> > > done
> > > > at all, is usually part of weekly or monthly "housekeeping" and done
> > after
> > > > hours.

> > > > Also, there's usually no need to PACK tables since the deleted
records
> > are
> > > > filtered out by default. Usually developers who ask questions about
> > > PACKing
> > > > tables have one of two situations: they have really large tables and
> > lots
> > > of
> > > > deleted records and want to "recycle" the deleted records (not sure
> how
> > > you
> > > > would do this in VB) or they want to re-use primary keys, which is
not
> a
> > > > good idea in a relational database.

> > > > --
> > > > Cindy Winegarden  MCSD, Microsoft Visual FoxPro MVP

> > > > http://msdn.microsoft.com/vfoxpro  http://foxcentral.net



> > > > > After marking the records in a FoxPro table for deletion from VB
> 6.0,
> > > I'm
> > > > > attempting to issue a "pack" command, but am not quite sure how to
> do
> > > it.
> > > > > Does anyone know?



Mon, 05 Sep 2005 04:00:22 GMT  
 Packing a Table from VB
Check out DRVVFP.HLP for supported commands and functions in VFPODBC.DLL


Quote:
> Anders,

> I'm still getting "file is in use".  When I try to issue a "CLOSE
DATABASES"
> comand right before the line

> Connection.Execute("SET EXCLUSIVE ON;PACK Employees")

> I get the error a syntax error.  Thanks for your feedback.



> > Then try Conn.execute ("set exclusive on;pack tabelname")
> > -Anders

> > There a KB aerticle Q234756 "How to pack a table throght the Visual
FxoPro
> > ODBC driver"
> > Here's some sample VC++ code
> > #include <afxdb.h>
> > #include <iostream.h>

> > void main()
> > {
> >   try
> >   {
> >   CDatabase db;
> >   db.OpenEx("driver=Microsoft Visual FoxPro

Driver;sourcetype=dbc;sourcedb=C:\\Q234756_TEST\\test.dbc;exclusive=yes");

- Show quoted text -

Quote:
> >   db.ExecuteSQL("set exclusive on;pack t1");
> >   cout << "Table Packed!" <<endl;
> >   db.Close();
> >   }
> >   catch(CDBException *E)
> >   {
> >    cout << E->m_strError <<endl;
> >   }
> > }


> > > I'm assuming that the .Execute method on an ADO Connection object can
be
> > > used to send any FoxPro message.  Because my table is "in use" when I
> try
> > to
> > > PACK it, I'm trying to send "CLOSE DATABASES" to close it first.

> > > When I do this, I get the error,

> > > Run-time error '-2147217911 (80040e09)

> > > [Microsoft][OCBC Visual FoxPro Driver]Syntax error or access
violation.

> > > These commands work in the FoxPro command window.  The connection
string
> > I'm
> > > using is as follows:

> > > Driver={Microsoft Visual FoxPro Driver};SourceType=DBC;" & _
> > >            "SourceDB=c:\JFLTime\data\JFLTime.dbc;" & _
> > >            "Exclusive=Yes;"

> > > What's my next step?



> > > > Hi Curt,

> > > > Eric posted two references on how to do it. I'd like to point out
that
> > > PACK
> > > > requires exclusive use of the tables, and is not something you can
do
> > > every
> > > > time you delete a record in a production situation. PACKing tables,
if
> > > done
> > > > at all, is usually part of weekly or monthly "housekeeping" and done
> > after
> > > > hours.

> > > > Also, there's usually no need to PACK tables since the deleted
records
> > are
> > > > filtered out by default. Usually developers who ask questions about
> > > PACKing
> > > > tables have one of two situations: they have really large tables and
> > lots
> > > of
> > > > deleted records and want to "recycle" the deleted records (not sure
> how
> > > you
> > > > would do this in VB) or they want to re-use primary keys, which is
not
> a
> > > > good idea in a relational database.

> > > > --
> > > > Cindy Winegarden  MCSD, Microsoft Visual FoxPro MVP

> > > > http://msdn.microsoft.com/vfoxpro  http://foxcentral.net



> > > > > After marking the records in a FoxPro table for deletion from VB
> 6.0,
> > > I'm
> > > > > attempting to issue a "pack" command, but am not quite sure how to
> do
> > > it.
> > > > > Does anyone know?



Mon, 05 Sep 2005 02:01:07 GMT  
 Packing a Table from VB
Well, at least this gives me a different error, which is progress:

Run-time error '-2147467259(80004005)':

[Microsoft][ODBC Driver Manager] Data soure name not found and no default
driver specified.


Quote:
> Hi
> I tried this from inside VFP but it should work with some changes in VB
> oconn = NEWOBJECT('adodb.connection')
> connstrx=[Driver=Microsoft Visual FoxPro Driver;SourceType=DBC;] + ;
>            "SourceDB=d:\projects\tests\testdata.dbc;" + ;
>            "Exclusive=Yes;"
> oconn.connectionstring=connstrx
> oconn.Open(oconn.ConnectionString)
> oconn.Execute("pack phonetypes")

> I had a terrible lot of problems till it dawned on me that the 'Not a
table'
> messages occured with VFP8 tables with an AutoInc column.
> -Anders



> > Anders,

> > I'm still getting "file is in use".  When I try to issue a "CLOSE
> DATABASES"
> > comand right before the line

> > Connection.Execute("SET EXCLUSIVE ON;PACK Employees")

> > I get the error a syntax error.  Thanks for your feedback.



> > > Then try Conn.execute ("set exclusive on;pack tabelname")
> > > -Anders

> > > There a KB aerticle Q234756 "How to pack a table throght the Visual
> FxoPro
> > > ODBC driver"
> > > Here's some sample VC++ code
> > > #include <afxdb.h>
> > > #include <iostream.h>

> > > void main()
> > > {
> > >   try
> > >   {
> > >   CDatabase db;
> > >   db.OpenEx("driver=Microsoft Visual FoxPro

> Driver;sourcetype=dbc;sourcedb=C:\\Q234756_TEST\\test.dbc;exclusive=yes");
> > >   db.ExecuteSQL("set exclusive on;pack t1");
> > >   cout << "Table Packed!" <<endl;
> > >   db.Close();
> > >   }
> > >   catch(CDBException *E)
> > >   {
> > >    cout << E->m_strError <<endl;
> > >   }
> > > }


> > > > I'm assuming that the .Execute method on an ADO Connection object
can
> be
> > > > used to send any FoxPro message.  Because my table is "in use" when
I
> > try
> > > to
> > > > PACK it, I'm trying to send "CLOSE DATABASES" to close it first.

> > > > When I do this, I get the error,

> > > > Run-time error '-2147217911 (80040e09)

> > > > [Microsoft][OCBC Visual FoxPro Driver]Syntax error or access
> violation.

> > > > These commands work in the FoxPro command window.  The connection
> string
> > > I'm
> > > > using is as follows:

> > > > Driver={Microsoft Visual FoxPro Driver};SourceType=DBC;" & _
> > > >            "SourceDB=c:\JFLTime\data\JFLTime.dbc;" & _
> > > >            "Exclusive=Yes;"

> > > > What's my next step?



> > > > > Hi Curt,

> > > > > Eric posted two references on how to do it. I'd like to point out
> that
> > > > PACK
> > > > > requires exclusive use of the tables, and is not something you can
> do
> > > > every
> > > > > time you delete a record in a production situation. PACKing
tables,
> if
> > > > done
> > > > > at all, is usually part of weekly or monthly "housekeeping" and
done
> > > after
> > > > > hours.

> > > > > Also, there's usually no need to PACK tables since the deleted
> records
> > > are
> > > > > filtered out by default. Usually developers who ask questions
about
> > > > PACKing
> > > > > tables have one of two situations: they have really large tables
and
> > > lots
> > > > of
> > > > > deleted records and want to "recycle" the deleted records (not
sure
> > how
> > > > you
> > > > > would do this in VB) or they want to re-use primary keys, which is
> not
> > a
> > > > > good idea in a relational database.

> > > > > --
> > > > > Cindy Winegarden  MCSD, Microsoft Visual FoxPro MVP

> > > > > http://msdn.microsoft.com/vfoxpro  http://foxcentral.net



> > > > > > After marking the records in a FoxPro table for deletion from VB
> > 6.0,
> > > > I'm
> > > > > > attempting to issue a "pack" command, but am not quite sure how
to
> > do
> > > > it.
> > > > > > Does anyone know?



Mon, 05 Sep 2005 08:11:54 GMT  
 Packing a Table from VB
Hi Curt
At what point do you get the error. Can you do anything with you're
connection. like
Debug.print oconn.connectionstring
or oRecordSet=oconn.Execute("SELECT * FROM anytable_ast_all")

Could you post the  lines of VB code leading up to sending the PACK command
-Anders


Quote:
> Well, at least this gives me a different error, which is progress:

> Run-time error '-2147467259(80004005)':

> [Microsoft][ODBC Driver Manager] Data soure name not found and no default
> driver specified.



> > Hi
> > I tried this from inside VFP but it should work with some changes in VB
> > oconn = NEWOBJECT('adodb.connection')
> > connstrx=[Driver=Microsoft Visual FoxPro Driver;SourceType=DBC;] + ;
> >            "SourceDB=d:\projects\tests\testdata.dbc;" + ;
> >            "Exclusive=Yes;"
> > oconn.connectionstring=connstrx
> > oconn.Open(oconn.ConnectionString)
> > oconn.Execute("pack phonetypes")

> > I had a terrible lot of problems till it dawned on me that the 'Not a
> table'
> > messages occured with VFP8 tables with an AutoInc column.
> > -Anders



> > > Anders,

> > > I'm still getting "file is in use".  When I try to issue a "CLOSE
> > DATABASES"
> > > comand right before the line

> > > Connection.Execute("SET EXCLUSIVE ON;PACK Employees")

> > > I get the error a syntax error.  Thanks for your feedback.



> > > > Then try Conn.execute ("set exclusive on;pack tabelname")
> > > > -Anders

> > > > There a KB aerticle Q234756 "How to pack a table throght the Visual
> > FxoPro
> > > > ODBC driver"
> > > > Here's some sample VC++ code
> > > > #include <afxdb.h>
> > > > #include <iostream.h>

> > > > void main()
> > > > {
> > > >   try
> > > >   {
> > > >   CDatabase db;
> > > >   db.OpenEx("driver=Microsoft Visual FoxPro

Driver;sourcetype=dbc;sourcedb=C:\\Q234756_TEST\\test.dbc;exclusive=yes");

- Show quoted text -

Quote:
> > > >   db.ExecuteSQL("set exclusive on;pack t1");
> > > >   cout << "Table Packed!" <<endl;
> > > >   db.Close();
> > > >   }
> > > >   catch(CDBException *E)
> > > >   {
> > > >    cout << E->m_strError <<endl;
> > > >   }
> > > > }


> > > > > I'm assuming that the .Execute method on an ADO Connection object
> can
> > be
> > > > > used to send any FoxPro message.  Because my table is "in use"
when
> I
> > > try
> > > > to
> > > > > PACK it, I'm trying to send "CLOSE DATABASES" to close it first.

> > > > > When I do this, I get the error,

> > > > > Run-time error '-2147217911 (80040e09)

> > > > > [Microsoft][OCBC Visual FoxPro Driver]Syntax error or access
> > violation.

> > > > > These commands work in the FoxPro command window.  The connection
> > string
> > > > I'm
> > > > > using is as follows:

> > > > > Driver={Microsoft Visual FoxPro Driver};SourceType=DBC;" & _
> > > > >            "SourceDB=c:\JFLTime\data\JFLTime.dbc;" & _
> > > > >            "Exclusive=Yes;"

> > > > > What's my next step?



> > > > > > Hi Curt,

> > > > > > Eric posted two references on how to do it. I'd like to point
out
> > that
> > > > > PACK
> > > > > > requires exclusive use of the tables, and is not something you
can
> > do
> > > > > every
> > > > > > time you delete a record in a production situation. PACKing
> tables,
> > if
> > > > > done
> > > > > > at all, is usually part of weekly or monthly "housekeeping" and
> done
> > > > after
> > > > > > hours.

> > > > > > Also, there's usually no need to PACK tables since the deleted
> > records
> > > > are
> > > > > > filtered out by default. Usually developers who ask questions
> about
> > > > > PACKing
> > > > > > tables have one of two situations: they have really large tables
> and
> > > > lots
> > > > > of
> > > > > > deleted records and want to "recycle" the deleted records (not
> sure
> > > how
> > > > > you
> > > > > > would do this in VB) or they want to re-use primary keys, which
is
> > not
> > > a
> > > > > > good idea in a relational database.

> > > > > > --
> > > > > > Cindy Winegarden  MCSD, Microsoft Visual FoxPro MVP

> > > > > > http://msdn.microsoft.com/vfoxpro  http://foxcentral.net



> > > > > > > After marking the records in a FoxPro table for deletion from
VB
> > > 6.0,
> > > > > I'm
> > > > > > > attempting to issue a "pack" command, but am not quite sure
how
> to
> > > do
> > > > > it.
> > > > > > > Does anyone know?



Mon, 05 Sep 2005 20:01:13 GMT  
 Packing a Table from VB


Quote:
> Hi Curt
> At what point do you get the error. Can you do anything with you're
> connection. like
> Debug.print oconn.connectionstring
> or oRecordSet=oconn.Execute("SELECT * FROM anytable_ast_all")

> Could you post the  lines of VB code leading up to sending the PACK
command
> -Anders



> > Well, at least this gives me a different error, which is progress:

> > Run-time error '-2147467259(80004005)':

> > [Microsoft][ODBC Driver Manager] Data soure name not found and no
default
> > driver specified.



> > > Hi
> > > I tried this from inside VFP but it should work with some changes in
VB
> > > oconn = NEWOBJECT('adodb.connection')
> > > connstrx=[Driver=Microsoft Visual FoxPro Driver;SourceType=DBC;] + ;
> > >            "SourceDB=d:\projects\tests\testdata.dbc;" + ;
> > >            "Exclusive=Yes;"
> > > oconn.connectionstring=connstrx
> > > oconn.Open(oconn.ConnectionString)
> > > oconn.Execute("pack phonetypes")

> > > I had a terrible lot of problems till it dawned on me that the 'Not a
> > table'
> > > messages occured with VFP8 tables with an AutoInc column.
> > > -Anders



> > > > Anders,

> > > > I'm still getting "file is in use".  When I try to issue a "CLOSE
> > > DATABASES"
> > > > comand right before the line

> > > > Connection.Execute("SET EXCLUSIVE ON;PACK Employees")

> > > > I get the error a syntax error.  Thanks for your feedback.



> > > > > Then try Conn.execute ("set exclusive on;pack tabelname")
> > > > > -Anders

> > > > > There a KB aerticle Q234756 "How to pack a table throght the
Visual
> > > FxoPro
> > > > > ODBC driver"
> > > > > Here's some sample VC++ code
> > > > > #include <afxdb.h>
> > > > > #include <iostream.h>

> > > > > void main()
> > > > > {
> > > > >   try
> > > > >   {
> > > > >   CDatabase db;
> > > > >   db.OpenEx("driver=Microsoft Visual FoxPro

> Driver;sourcetype=dbc;sourcedb=C:\\Q234756_TEST\\test.dbc;exclusive=yes");
> > > > >   db.ExecuteSQL("set exclusive on;pack t1");
> > > > >   cout << "Table Packed!" <<endl;
> > > > >   db.Close();
> > > > >   }
> > > > >   catch(CDBException *E)
> > > > >   {
> > > > >    cout << E->m_strError <<endl;
> > > > >   }
> > > > > }


> > > > > > I'm assuming that the .Execute method on an ADO Connection
object
> > can
> > > be
> > > > > > used to send any FoxPro message.  Because my table is "in use"
> when
> > I
> > > > try
> > > > > to
> > > > > > PACK it, I'm trying to send "CLOSE DATABASES" to close it first.

> > > > > > When I do this, I get the error,

> > > > > > Run-time error '-2147217911 (80040e09)

> > > > > > [Microsoft][OCBC Visual FoxPro Driver]Syntax error or access
> > > violation.

> > > > > > These commands work in the FoxPro command window.  The
connection
> > > string
> > > > > I'm
> > > > > > using is as follows:

> > > > > > Driver={Microsoft Visual FoxPro Driver};SourceType=DBC;" & _
> > > > > >            "SourceDB=c:\JFLTime\data\JFLTime.dbc;" & _
> > > > > >            "Exclusive=Yes;"

> > > > > > What's my next step?



> > > > > > > Hi Curt,

> > > > > > > Eric posted two references on how to do it. I'd like to point
> out
> > > that
> > > > > > PACK
> > > > > > > requires exclusive use of the tables, and is not something you
> can
> > > do
> > > > > > every
> > > > > > > time you delete a record in a production situation. PACKing
> > tables,
> > > if
> > > > > > done
> > > > > > > at all, is usually part of weekly or monthly "housekeeping"
and
> > done
> > > > > after
> > > > > > > hours.

> > > > > > > Also, there's usually no need to PACK tables since the deleted
> > > records
> > > > > are
> > > > > > > filtered out by default. Usually developers who ask questions
> > about
> > > > > > PACKing
> > > > > > > tables have one of two situations: they have really large
tables
> > and
> > > > > lots
> > > > > > of
> > > > > > > deleted records and want to "recycle" the deleted records (not
> > sure
> > > > how
> > > > > > you
> > > > > > > would do this in VB) or they want to re-use primary keys,
which
> is
> > > not
> > > > a
> > > > > > > good idea in a relational database.

> > > > > > > --
> > > > > > > Cindy Winegarden  MCSD, Microsoft Visual FoxPro MVP


http://cindywinegarden.adsl.duke.edu

- Show quoted text -

Quote:
> > > > > > > http://msdn.microsoft.com/vfoxpro  http://foxcentral.net



> > > > > > > > After marking the records in a FoxPro table for deletion
from
> VB
> > > > 6.0,
> > > > > > I'm
> > > > > > > > attempting to issue a "pack" command, but am not quite sure
> how
> > to
> > > > do
> > > > > > it.
> > > > > > > > Does anyone know?



Mon, 05 Sep 2005 23:28:11 GMT  
 
 [ 17 post ]  Go to page: [1] [2]

 Relevant Pages 

1. Packing a Table from a VB Front End

2. how VB update Table A INNER JOIN Table B, Set A.co=B.ID

3. how VB update Table A INNER JOIN Table B, Set A.co=B.ID

4. Pack Memo or Pack causes Trigger Failed

5. Packing a table

6. Packing a Table

7. Packing Tables

8. Can't pack a table from within my application

9. unable to pack a table

10. packing a table when using a Grid

11. Packing a child table

12. Packing Large Tables

 

 
Powered by phpBB® Forum Software