Discussion:
URGENT: FoxPro COM Object
(too old to reply)
Faraz Khan
2004-09-11 05:02:14 UTC
Permalink
Please Please Please. I am in time crunch and need to have fast access
to a FoxPro database (*.dbc file). Thru VB, I tried using both OLE-DB
and ODBC drivers for fox pro to insert/update data in that database.
However, there are certain code in the foxpro triggers and field
validation rules that are not supported under ODBC or OLE-DB. So my
app fails.

Up until now I have been editing the stored procedures in foxpro to
comment out the incompatible code that causes the problem. But I can
no longer do that. The 3rd party app which has the foxpro DB has been
updated in such a way that changing the stored procedures codes will
break the 3rd party app, which is not an option anymore.

Someone suggested creating a very simple 1 method COM object using
foxpro. Thet single method will take a string as input and return a
ADO25.Recordset object. The method will exeucte ANY sql passed to it
after connecting to the DBC file. Since the method is written in
foxpro it should have no problems with the stored procedures within
the DBC. Is this possible??

Please help me write this COM object. I have no idea what to do or
how to begin. Please keep in mind that this COM object must not have
any GUI, since its has to run in ASP, ASP.NET as well as VB.NET
console app as a batch.
Eric den Doop
2004-09-11 09:04:58 UTC
Permalink
Hello, Faraz!

You have to create a COM DLL in VFP. A COM server is a OLEPUBLIC class. A
sample class definition is:

DEFINE CLASS bizrules AS Custom OLEPUBLIC
PROCEDURE DeleteCustomer (tnCustomerID As Integer)
* do some checking here...
DELETE FROM Customer WHERE id == tnCustomerID
RETURN some_Value && for example .T. if DELETE succeeded
ENDPROC
ENDDEFINE

See VFP help on DEFINE CLASS for more info.
--
Eric den Doop
www.foxite.com - The Home Of The Visual FoxPro Experts - Powered By VFP8
Anders Altberg
2004-09-11 14:13:32 UTC
Permalink
RI trigger code, validation rules, and database events will run whether you
execute queries from an ADODB connectrion or through a native VFP
application, or even the VFP IDE. They are there to protext the data from
possible harm
-Anders
Post by Faraz Khan
Please Please Please. I am in time crunch and need to have fast access
to a FoxPro database (*.dbc file). Thru VB, I tried using both OLE-DB
and ODBC drivers for fox pro to insert/update data in that database.
However, there are certain code in the foxpro triggers and field
validation rules that are not supported under ODBC or OLE-DB. So my
app fails.
Up until now I have been editing the stored procedures in foxpro to
comment out the incompatible code that causes the problem. But I can
no longer do that. The 3rd party app which has the foxpro DB has been
updated in such a way that changing the stored procedures codes will
break the 3rd party app, which is not an option anymore.
Someone suggested creating a very simple 1 method COM object using
foxpro. Thet single method will take a string as input and return a
ADO25.Recordset object. The method will exeucte ANY sql passed to it
after connecting to the DBC file. Since the method is written in
foxpro it should have no problems with the stored procedures within
the DBC. Is this possible??
Please help me write this COM object. I have no idea what to do or
how to begin. Please keep in mind that this COM object must not have
any GUI, since its has to run in ASP, ASP.NET as well as VB.NET
console app as a batch.
Faraz Khan
2004-09-12 22:52:31 UTC
Permalink
I do want them to run. However, when i insert a new record in a
table, using VFP ODBC drivers from a VB app, I get an error saying
something like command or trigger not supported. I am able to edit
the stored procedure inside the database using VFP 6.0. Even though i
dont understand the code much, when i comment out certain portions of
the trigger or rule, the VB insert app starts working.

I had no problem with that method, until now. The 3rd party app which
has this database has been updated in such a way that if i comment out
code in the stored procedures the 3rd party app breaks.

So i thought if the insert command can be executed natively within VFP
runtime environment, then every one will be happy, and i wont have to
comment out the unsupported code.

I have very little experience in VFP, so i dont know how to create a
COM object that can do that. Ofcourse i can learn it, but i needed it
urgently.
Post by Anders Altberg
RI trigger code, validation rules, and database events will run whether you
execute queries from an ADODB connectrion or through a native VFP
application, or even the VFP IDE. They are there to protext the data from
possible harm
-Anders
Post by Faraz Khan
Please Please Please. I am in time crunch and need to have fast access
to a FoxPro database (*.dbc file). Thru VB, I tried using both OLE-DB
and ODBC drivers for fox pro to insert/update data in that database.
However, there are certain code in the foxpro triggers and field
validation rules that are not supported under ODBC or OLE-DB. So my
app fails.
Up until now I have been editing the stored procedures in foxpro to
comment out the incompatible code that causes the problem. But I can
no longer do that. The 3rd party app which has the foxpro DB has been
updated in such a way that changing the stored procedures codes will
break the 3rd party app, which is not an option anymore.
Someone suggested creating a very simple 1 method COM object using
foxpro. Thet single method will take a string as input and return a
ADO25.Recordset object. The method will exeucte ANY sql passed to it
after connecting to the DBC file. Since the method is written in
foxpro it should have no problems with the stored procedures within
the DBC. Is this possible??
Please help me write this COM object. I have no idea what to do or
how to begin. Please keep in mind that this COM object must not have
any GUI, since its has to run in ASP, ASP.NET as well as VB.NET
console app as a batch.
Anders Altberg
2004-09-12 23:30:52 UTC
Permalink
Faraz,
VFPODBC only supports VFP databases up to the VFP 6 version. If a database
made in a later version utilzes any of the data engine enhancements added in
VFP 7 or later then VFPODBC won't work. The recommendation is to download
and use VFPOLEDB. unless you've already have it installed.
The VFP commands supported in triggers, validation rules and column defaults
are documented in DRVVFP.HLP. Search for it it in your Windows directory.
How to create a VFP COM server and the various kinds of compilöations ind
ionstall options is detailed in the docs. You can also find VFP's
documentation on the MSDN Library disks.
-Anders
Post by Faraz Khan
I do want them to run. However, when i insert a new record in a
table, using VFP ODBC drivers from a VB app, I get an error saying
something like command or trigger not supported. I am able to edit
the stored procedure inside the database using VFP 6.0. Even though i
dont understand the code much, when i comment out certain portions of
the trigger or rule, the VB insert app starts working.
I had no problem with that method, until now. The 3rd party app which
has this database has been updated in such a way that if i comment out
code in the stored procedures the 3rd party app breaks.
So i thought if the insert command can be executed natively within VFP
runtime environment, then every one will be happy, and i wont have to
comment out the unsupported code.
I have very little experience in VFP, so i dont know how to create a
COM object that can do that. Ofcourse i can learn it, but i needed it
urgently.
Post by Anders Altberg
RI trigger code, validation rules, and database events will run whether you
execute queries from an ADODB connectrion or through a native VFP
application, or even the VFP IDE. They are there to protext the data from
possible harm
-Anders
Post by Faraz Khan
Please Please Please. I am in time crunch and need to have fast access
to a FoxPro database (*.dbc file). Thru VB, I tried using both OLE-DB
and ODBC drivers for fox pro to insert/update data in that database.
However, there are certain code in the foxpro triggers and field
validation rules that are not supported under ODBC or OLE-DB. So my
app fails.
Up until now I have been editing the stored procedures in foxpro to
comment out the incompatible code that causes the problem. But I can
no longer do that. The 3rd party app which has the foxpro DB has been
updated in such a way that changing the stored procedures codes will
break the 3rd party app, which is not an option anymore.
Someone suggested creating a very simple 1 method COM object using
foxpro. Thet single method will take a string as input and return a
ADO25.Recordset object. The method will exeucte ANY sql passed to it
after connecting to the DBC file. Since the method is written in
foxpro it should have no problems with the stored procedures within
the DBC. Is this possible??
Please help me write this COM object. I have no idea what to do or
how to begin. Please keep in mind that this COM object must not have
any GUI, since its has to run in ASP, ASP.NET as well as VB.NET
console app as a batch.
Loading...