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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CGI Script for accessing a MS Access DB

Status
Not open for further replies.

TonyMacaroni

IS-IT--Management
Jul 5, 2001
12
0
0
GB
Urgent help needed here!

Does anyone know of a good cgi script that will take a user entered keyword and search a MS Access DB? I'm fairly new to CGI programming so I don't know enough about it to do one myself.

Any help would be greatly appreciated. Cheers!
 
I've just tried that link and its saying they don't do the script anymore, do you know of any other places? Cheers.
 
The following leaves out a lot of detail. I usually either use text files or MySQL or PostgreSQL, so I am not up to speed on the Win32::OBDC SQL usage. But, maybe this will illustrate the flow a little. There is a good book on this stuff, 'Programming the Perl DBI' by Alligator Descarte and Tim Bunce (I think) published by OReilly. I think it is about $35(US) and is well worth the price, if you are going to be playing Database games with Perl.

HTH


#!perl

use CGI;
use Win32::ODBC;

$cgi = new CGI;
print $cgi->header;
print $cgi->start_html;

# try to retreive a search_term
$term = $cgi->param('search_term');

if ($term)
{
# establish a connection to the ODBC data source
$db = new Win32::ODBC("DSN=Your_ODBC_Data_Source;UID=your_uid;PWD=your_password")
or die Win32::ODBC::Error();

# do your sql executes/fetches
# print output to the browser.
# sorry, I don't have an example of doing this handy.


# close the database connection
if ($db) { $db->Close(); }
}

else
{
print &quot;<p>Sorry, no search term submitted</p>\n&quot;;
}

# finish HTML output
print $cgi->end_html;




keep the rudder amid ship and beware the odd typo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top