Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reindex Foxpro Tables from Web

Status
Not open for further replies.

rpack78

Programmer
Oct 1, 2004
35
US
Hello everyone!

I need a lot of help since I am not a foxpro programmer. I wrote a web page using Perl/CGI that uses XBase to insert records into a foxpro table. The problem is, XBase does not update the .cdx index files so the 3rd party program that is reading the tables cannot see the inserted records. If I reindex the table, they show up.

I need to reindex the table after the records are inserted. I have read a little about COM servers and was wondering how I could accomplish this.

Thanks,
Ryan
 
Hello Ryan,

To be honest, your approach is probably not the best way to update foxpro tables - as you have found out.

I would recommend that you use the VFP OLEDB provider or the older ODBC driver for updating the table... but I'm guessing that you're not using IIS - perhaps Apache? - and that is not an option.

Do you have the xBase program running as a kind of 'shell' command from the CGI? If so, you could PROBABLY convert it to VFP and run that instead.

I have no experience of using it BUT


Lists a product that MIGHT help.


Regards

Griff
Keep [Smile]ing
 
Actually, I am using IIS. I usually use Apache on Unix, but this just happens to be on my clients Intranet server. I have tried using ODBC, but I cannot successfully connect to the database. DBI::ODBC gives me an error (something about SQLSetEnvAttr) and I cannot get it to work.

How can I use VFP OLEDB?

Thanks for your responses,
Ryan
 
You would probably need to firstly change your page to an .asp version (I don't know how to use Perl/CGI to access the ODBC).

Then install the VFP Version 9 VFPOLEDB from the microsoft web site.

After that you've a fair amount of work to do!



Regards

Griff
Keep [Smile]ing
 
Well, that is a problem. I don't have time to learn ASP and redo the site. They need this working ASAP and I have to deliver a solution. It doesn't have to be the best solution, just has to work. :)

Back to my original plan, is there a way to call an exe or something after I insert the records that will reindex the tables? I think this will be the fastest way to get this working.

Thanks,
Ryan
 
You can get your perl/cgi to execute an .exe, but it's going to need exclusive access to the table - i.e. your third party program would have to leave the tables while the reindex is done.

That said, the rest of it's pretty easy - if you have a copy of VFP to hand. In fact, if you send me details of the table name and the indexes, I'll happily write a little .exe for you to use - you can pass the path as a parameter or something.

Do you have skype?

Regards

Griff
Keep [Smile]ing
 
Man, this is complicated. I was hoping I could reindex without needing exclusive access, but I guess that is not possible. I will have to go another route. I will talk to my friend that knows ColdFusion and see if he can write a script that uses ODBC.

Thanks for the offer, though.

Ryan
 
There isn't necessarily any need for the .DBF to have any indexes on it... If you are just adding records from the Perl script, then a VFP program could append from the .DBF used by Perl and Into a main table (which would be indexed properly).


Who defined the structure/indexes of the .DBF that you have to access? Can the VFP program be changed now to make this process more elegant?

- Bill

Get the best answers to your questions -- See FAQ481-4875.
 
Atually, I am sort adding some functionality to (hacking) some 3rd party software. Its called SMART and is used for student records. All of the tables came with the software and apparently it reads the index files first and then cross references the tables to find students in the database. If I knew more about foxpro, I would just make a foxpro application (I do own Visual Studio 6) that inserted the new students. Unfortunately I don't and I already charged for the program I wrote with Perl. It inserts records fine, they just don't show up in SMART until I reindex.

Ryan
 
Do you know how to access COM / ActiveX controls from within Perl? it wouldn't be hard to create a COM server in VFP6 that would insert a record with the right values... (as was mentioned earlier).

This code would be enough:
Code:
DEFINE CLASS DtaAccess AS session OLEPUBLIC
  PROCEDURE AddRecord( cFile, Fld1, Val1, Fld2, Val2 )
    use (cFile) alias DataFile
    APPEND BLANK
    REPLACE (Fld1) WITH Val1, ;
            (Fld2) WITH Val2
    USE
    RETURN .T.
  ENDPROC
ENDDEFINE

To use it from most COM-enabled languages (if it is compiled into a project called GetSmart.pjx/dll):
xx = createobject('getsmart.dtaAccess')
xx.AddRecord('c:\path\data.dbf','id',1,'name','George')


- Bill

Get the best answers to your questions -- See FAQ481-4875.
 
Cool, this looks like what I want to do. I will have to figure out how to access a COM control with Perl, but it shouldn't be too hard. Don't you just have to put the code in with the HTML like JavaScript? I guess I don't quite understand how it works. Does the browser call the COM object or the Server?

Ryan
 
My code is just a "rough draft"... it's not tested, or thorough, but should give you an idea of what you need.

To make the COM server DLL, you'd do these steps:
1) Put your code (including the class definition) into a .PRG file.
2) create a project with "MODIFY PROJECT (projectname)" command
3) Add the .PRG file to the project
4) click "Build", and select "build a DLL"

You're done.
The .DLL is now already registered for COM on that computer.

To register it for COM on another computer, copy the DLL & VFP support files (described at and run the command: REGSVR32 yourdllfile.DLL


- Bill

Get the best answers to your questions -- See FAQ481-4875.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top