Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Learning what CLASSPATH is about
Message
 
To
01/12/2003 10:17:45
General information
Forum:
Java
Category:
Databases
Miscellaneous
Thread ID:
00853953
Message ID:
00854702
Views:
53
Hi John,

This can be done using perl to access a VFP free table, or a table that is a member of a DBC, under windows. You would need to have the DBI, ODBC and CGI modules installed. Here is an example of updating a VFP table named "example". The entire script can be downloaded from my site. The name of the zip file containing it is perl2vfp.ZIP.

In this example I create an ODBC connection name vfp1 using the windows wizard. Once I have the ODBC created, perl piggy-backs onto it using its DBI ODBC modules to work with the database.

You could do a search of goggle to see exactly what perl modules would need for scounix, etc, and how to create a unix ODBC connection to your vfp tables. Perl provides the DBI to work with databases in about every possible scenario.

If you think the perl2vfp.ZIP might help, it can be downloaded at:

http://www.smvfp.com

Below is some code I clipped from one of the perl2vfp.ZIP apps:
#!/usr/bin/perl 

use DBI;

use DBD::ODBC;

use CGI qw( :all );
use CGI::Carp qw( fatalsToBrowser );

print "Content-type: text/html\n\n";

$the_db="vfp2pg";

$the_table="example1";

$the_host="localhost";

$the_user="VfP2Pg";

$the_pass_wd="HelloWorld";

sub do_main {

     ##perl streams an HTML form here to the client's
     ##browser.  When the client clicks on the submit
     ##button, this perl script is called by the "Action
     ##Post" which directs input from the form to 
     ##sub do_update().  The do_update sub is called like:
     
              &do_update();

}



sub do_update {

      $findrec="cno=".$FORM{'cno'};
      $lcno=$FORM{'cno'};
      $lfirst="'".$FORM{'first'}."'";
      $llast="'".$FORM{'last'}."'";
      $ldate_it="'".$FORM{'date_it'}."'";
      $lcompany="'".$FORM{'company'}."'";
      $laddress="'".$FORM{'address'}."'";
      $lcity="'".$FORM{'city'}."'";
      $lstate="'".$FORM{'state'}."'";
      $lpostal="'".$FORM{'postal'}."'";
      $lphone="'".$FORM{'phone'}."'";
      $lemail="'".$FORM{'email'}."'";
      $lpass_key="'".$FORM{'pass_key'}."'";
      $lpayby="'".$FORM{'payby'}."'";
      $lcardtype="'".$FORM{'cardtype'}."'";
      $lcardholder="'".$FORM{'cardholder'}."'";
      $lcardnumber="'".$FORM{'cardnumber'}."'";
      $lcardmonth="'".$FORM{'cardmonth'}."'";
      $lcardyear="'".$FORM{'cardyear'}."'";
      $lamount=$FORM{'amount'};
      $lprocessed="'".$FORM{'processed'}."'";
	  
      $the_update="UPDATE $the_table SET 
first=".$lfirst.",last=".$llast.",company=".$lcompany,
",address=".$laddress.",city=".$lcity.",state=".
$lstate.",postal=".$lpostal.",phone=".$lphone.
",email=".$lemail.",pass_key=".$lpass_key.",
payby=".$lpayby.",cardtype=".$lcardtype.",
cardholder=".$lcardholder.",cardnumber=".$lcardnumber.",
cardmonth=".$lcardmonth.",cardyear=".$lcardyear.",
amount=".$lamount.",processed=".$lprocessed.",
thetime=datetime() WHERE cno=".$lcno;

###      print #the_update; ## Uncomment for debugging

      ############ Connect to the Database  ###########

      $dbh = DBI->connect('dbi:ODBC:vfp1');

      $dbh->{autocommit} = 0;  # enable transactions, if possible
      $dbh->{RaiseError} = 1;
      eval{ $sth = $dbh->prepare($the_update or die "Can't prepare the
 update statement: $DBI::errstr"); 
      $sth->execute or die "Can't execute update: $DBI::errstr"; 
      $dbh->commit;   # commit the changes if we get this far
      };

      if ($@) {
            print "Transaction aborted because $@";
            $dbh->rollback; # undo the incomplete changes
            # add other application on-error-clean-up code here
            if( defined($dbh) ) {
	              $dbh->disconnect();
            }
      } else {

            print "<html>";
            print "<head>";
            print "<title>The example record updated successfully</title>\n";
            print "</head>";
            print "<body TEXT='black' bgcolor='white'>";
            print "<h3><B>";
            print "<BR><BR>Your example update was successful. Please ";
            print "use your <FONT COLOR=\"\#FF0000\">Back</font> button to continue. ";
            print "</h3><B>";
            print "</body></html>";
      }
}
exit;
Regards,

LelandJ
Leland F. Jackson, CPA
Software - Master (TM)
smvfp@mail.smvfp.com
Software Master TM
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform