- 论坛徽章:
- 0
|
我用的代码在DOS下可以通过,可是在HTML里面没有办法显示出来,想请教一下为什么,能够回答我的真的好感谢!
代码如下:
#!/usr/bin/perl -w
use Win32::ODBC;
$DSN = "odbctest.mdb";
#$DBase = "odbctest.mdb";
#连接数据库
if (!($db = new Win32::ODBC($DSN))){
print "Content-type: text/html; charset=gb2312\n\n";
print "连接数据库失败.\n";
exit();
}
else{
print "Content-type: text/html; charset=gb2312\n\n";
print "连接数据库成功 (连接号:", $db->Connection(), ")\n";
}
#数据库中的表
print "数据库中的表:";
@tables = $db->TableList;
print @tables;
print "\n";
#选择数据表
if (! $db->Sql("SELECT * FROM [address] WHERE age>=20") ){
@FieldNames = $db->FieldNames();
$Cols = $#FieldNames + 1;
#表中字段数
#print "表address字段数:\n.$Colsn";
print "表address字段数:\n";
#字段列表
for ($i = 0; $i < $Cols; $i++){
print "$FieldNames[$i]t";
}
print "\n";
#列出的记录
while($db->FetchRow()) {
@values = $db->Data();
print @values;
print "\n";
}
}
#关闭链接
$db->Close(); |
|