Solved

CGI script to access database info and email it.

Posted on 2002-06-03
4
157 Views
Last Modified: 2013-12-25
I would like a CGI/Perl script that will pull data from a Access 2000 database and then create a text file and insert the data into it. Then the script will email the text file as an attatchment it to me. I have done this ASP already but would like to experiment with CGI. I have almost no experience with CGI/Perl
0
Comment
Question by:CUTTHEMUSIC
  • 2
  • 2
4 Comments
 
LVL 15

Expert Comment

by:samri
ID: 7053094
What OS and Webserver platform are you running anyway?  What is your Perl version?

To do such, you will need to;

1. Grab a copy of DBD::ODBC and DBI Perl module and have it installed on your system.

2. Configure ODBC Driver configured to the specified Access database that you need to connect to.

3. Next get your CGI code.  Make sure you had you CGI.pm module installed to enable the output to be "web-enabled"


--- sample code that will list all tables in some database.  Make sure you configure the ODBC connector to connect to that specified Acess Database.

---
#!c:\perl\bin\perl

use DBI;


 $dbh = DBI->connect('dbi:ODBC:RESKIT', 'user', 'password');

my @dbs = $dbh->tables();

foreach (@dbs) {
  print "== $_\n";
}
----------------

To see the usage of DBI modules, do a "perldoc DBI" from command prompt, it should give you the detailed description and some sample code that you could use.

good luck.
0
 
LVL 15

Accepted Solution

by:
samri earned 200 total points
ID: 7053184
What OS and Webserver platform are you running anyway?  What is your Perl version?

To do such, you will need to;

1. Grab a copy of DBD::ODBC and DBI Perl module and have it installed on your system.

2. Configure ODBC Driver configured to the specified Access database that you need to connect to.

3. Next get your CGI code.  Make sure you had you CGI.pm module installed to enable the output to be "web-enabled"


--- sample code that will list all tables in some database.  Make sure you configure the ODBC connector to connect to that specified Acess Database.

---
#!c:\perl\bin\perl

use DBI;


 $dbh = DBI->connect('dbi:ODBC:RESKIT', 'user', 'password');

my @dbs = $dbh->tables();

foreach (@dbs) {
  print "== $_\n";
}
----------------

To see the usage of DBI modules, do a "perldoc DBI" from command prompt, it should give you the detailed description and some sample code that you could use.

good luck.
0
 
LVL 12

Expert Comment

by:lexxwern
ID: 7053664
#!/usr/local/bin/perl -w

use DBI;
use warnings;


$dbh =
     DBI->connect ("DBI:mysql:database=...;host=...;port=...",$DBuser,$DBpass)
          or
     die $DBI::errstr;


$query = "select * ...";
$askquery = $dbh->prepare($query);

$getentry = $askquery->execute;




this is how to work with DBI..
0
 
LVL 12

Expert Comment

by:lexxwern
ID: 7077305
CUTTHEMUSIC, are you here?
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction:   Welcome to my first article ever. To begin with, the reason I write this article.  I participated in a question on Experts Exchange about the start command in Windows and there were some discussion about the usage. The discussio…
This article will show, step by step, how to integrate R code into a R Sweave document
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question