Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

CGI script to access database info and email it.

Posted on 2002-06-03
4
Medium Priority
?
162 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 800 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

Application Discovery Service in AWS

In the era of the cloud, customers migrating away from their existing on-premise infrastructure. This requires lots of planning, strategies, and effort to identify their existing resources and determine how best to migrate.  Datacenter migrations happen in four phases -

Question has a verified solution.

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

This tutorial will discuss fancy secure registration forms, with AJAX technology support. In this article I assume you already know HTML and some JS. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you mig…
In this tutorial I will show you how to make a simple HTML bar chart with the usage of WhizBase, If you want more information about WhizBase please read my previous articles at http://www.experts-exchange.com/ARTH_5123186.html (http://www.experts-ex…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

730 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