perl 5.8.9
大家好,
我成功地使用 DBI/DBD/ODBC 在现有的 Access 2003 (.mdb) 数据库中使用以下字符串创建了一个新表: $q = "CREATE TABLE memoTestA (name TEXT, addr TEXT)"; # 有效
但我不知道如何添加 MEMO 类型的字段,即 $q = "CREATE TABLE memoTestB (name TEXT, addr TEXT, desc MEMO)"; # 抛出语法错误
一定有办法——诀窍是什么?
使用 DBD::ODBC 到 Win32::OLE 的切换表单让我摆脱了 ->Execute stmt 引发的“错误语法”错误,但我没有看到在 Access 数据库中实际创建的表。嗯。
#-------------------------------
sub setUpDatasourceLocalAccessC($)
{ my $debug = 0;
my ( $dbFile) = @_;
#Choose appropriate version of Jet for your system
my $Jet = Win32::OLE->CreateObject('DAO.DBEngine.36') or die "Can't create Jet database engine.";
my $dbh = $Jet->OpenDatabase( $dbFile);
return $dbh;
}
#-------------------------------
sub createMemoTablePrepareC($)
{
my ($dbh_vdms) = @_;
print "entering createMemoTablePrepareC\n" if $debug;
my $errorHit = 0;
my @table_arry = ();
my @goodtable_arry = ();
my $q = undef;
if( !defined( $dbh_vdms)) {
_pushErrorMsg("db connection failed - ".$DBI::errstr);
$errorHit = 1;
} else {
$q = "CREATE TABLE memoTestC (name TEXT, addr TEXT)"; # works
$q = "CREATE TABLE memoTestC (name TEXT, addr TEXT, desc MEMO)"; #seems to work, no errmsg but dont see table appear in database
$dbh_vdms->Execute( $q);
if( my $errorMsg = $dbh_vdms->errstr ) {
_pushErrorMsg("create statement failed - ".$errorMsg);
$errorHit = 1;
}
$dbh_vdms->close();
$dbh_vdms->disconnect();
}
print "exiting createMemoTablePrepareC with errorHit=".$errorHit."\n" if $debug;
return $errorHit;
}
TIA,
仍在学习的史蒂夫