#!perl/bin/perl
use win32;
use Win32::ODBC;
use CGI qw(:standard);
$data="ibd_lib.txt";
$test="test.txt";
my (@statement); # array of sql statements
my $db=new Win32::ODBC("DSN=bisx;UID=;PWD=");
### report connection status
if (!$db) {
print "\nunable to connect to database!\n";
die();
}
### Open File for Reading
open(FR, "< $data") || die "cannot open $data for reading: $!";
###open(FW, "> $test") || die "cannot create $test: $!";
while(<FR>) {
### Write to Database
push @statement, "INSERT INTO UserTestingE (ID) VALUES (\t$_\n)";
### print FW $_;
}
### Close the file
close(FR) || die "cant close $ibd_lib: $!";
###close(FW) || die "cant close $test: $!"
### Close the database
$db->Close();
I don't have the DBI module i get this error:
Can't locate DBI.pm in @INC (@INC contains:
The only way that i know how to write to an access databse is using
the Win32::ODBC module just like above. I just don't know if i'm doing it
right or what is going on. Please take a look at it and tell me what you think.
the file is a comma delimited file that has about 10,000 lines and i need to take
each line and insert it one after another in an access database.
Thanks,
Elvin
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|