Help: Connect Perl and MSAccess database
From: Ranjith eyacheruvatt (ranjithepost_at_yahoo.co.in)
Date: 05/26/04
- Next message: William Kolln: "Array help needed please"
- Previous message: Lrmk: "Re: need help(urgent)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 26 May 2004 11:43:19 +0100 (BST) To: beginners@perl.org
Hello
Now I started in perl, I could do simple programs such as string manipulations, but i could not connect to
MSAccess database located at my server. This is the code i used.
file://=========ADO code start here========
print "Content-Type: text/html\n\n";
use "win32::OLE"
Set conn = Server.CreateObject("ADODB.Connection")
Set RS = Server.CreateObject("ADODB.RecordSet")
#TEST is the DNS
conn.Open "DSN=TEST"
RS.Open "SELECT * FROM WsCoupon", conn, adOpenDynamic, adLockPessimestic, adCMDText
WHILE NOT RS.EOF
Response.write "<br>"&RS("OrderID")
RS.MoveNext
WEND
RS.Close
conn.Close
file://==========ADO end here=====
file://===above code shows error as follows:
CGI Error
The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are:
syntax error at D:\Inetpub\wwwroot\ECouponInfoPages\HelloPerl.pl line 3, next token ???
Execution of D:\Inetpub\wwwroot\ECouponInfoPages\HelloPerl.pl aborted due to compilation errors.
#======ADO error ends here
i also tried ODBC code as follows,
#=======ODBC code here==========
print "Content-Type: text/html\n\n";
use DBI;
$dbh = dbi->connect('dbi:ODBC:eCoupon');
$sqlstatement="SELECT OrderID FROM WsCoupon";
$sth = $dbh->prepare($sqlstatement);
$sth->execute || die "Could not execute SQL statement ... maybe invalid?";
while (@row=$sth->fetchrow_array)
{
print "@row\n"
}
#==ODBC code ends here=======
This also make errors [on:- use DBI; statement]
#=========================
If you can help me either of this code please send me that code or refference.
Anticipatting an early reply.
Thanks in advance
Ranjith
email: ranjithepost@yahoo.co.in
Yahoo! India Matrimony: Find your partner online.
- Next message: William Kolln: "Array help needed please"
- Previous message: Lrmk: "Re: need help(urgent)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|