Win32::OLE and MSAccess - creating data type 'dbAutoIncrField'

T

Thomas Engel

Hi there,
I am new to this, so excuse me if I've missed the topic earlier, but I
couldn't find anything dealing with this:
I would like to create a MS Access field with data type
'dbAutoIncrField', using Win32::OLE. All other data types (dbLong,
dbInteger etc.) seem to work properly, only 'dbAutoIncrField' is not
assigned properly. I know I am using DAO which may be somewhat
outdated, but the property is described so why can I not use it?
Here comes a snippet:
use strict;
use warnings;
use Win32::OLE::Const 'Microsoft Access';
use Win32::OLE::Const 'Microsoft DAO';
my $Filename = "e:\\tmp\\test.mdb";
unlink $Filename;
my $Access = Win32::OLE->new('Access.Application', 'Quit');
my $Workspace = $Access->DBEngine->CreateWorkspace('', 'Admin', '');
my $Database = $Workspace->CreateDatabase($Filename, dbLangGeneral);
my $z=1;
my $TableDef = $Database->CreateTableDef('Test');
my $Field = $TableDef->CreateField('AutoInc', dbAutoIncrField);
$TableDef->Fields->Append($Field);
$Database->TableDefs->Append($TableDef);
my $Recordset = $Database->OpenRecordset('Test', dbOpenTable);
$Recordset->Addnew;
$Recordset->Fields('AutoInc')->{Value} =$z;
$Recordset->Update;
Thanx for reading this.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top