Article View: borland.public.cppbuilder.database.ado
Article #2730Re: How can I create Access table?
From: guba
Date: Wed, 26 Mar 2003 06:22
Date: Wed, 26 Mar 2003 06:22
66 lines
2520 bytes
2520 bytes
Helo Vladimir
Thank you the example, but I cant it run. The BCB 5 show me a few errors.
"Vladimir Afanasyev" <avv@systema.kiev.ua> wrote in message
news:3e808207$1@newsgroups.borland.com...
Hi,
"guba" <admin@coka.co.yu> wrote:
>How can I create Access table?
Next sample creates new Access database (c:/new.md) and
adds new table (MyTable) in this database:
(Some additional try, catch preferable)
void __fastcall TForm1::Button1Click(TObject *Sender)
{
#define adVarWChar 202
#define adInteger 3
Variant Catalog;
Variant Table;
Variant TablesDataBase;
Variant Columns;
if(FileExists("C://New.mdb"))
{
ShowMessage("Database exist");
Application->Terminate();
return;
}
Catalog=Variant::CreateObject("ADOX.Catalog");
Table=Variant::CreateObject("ADOX.Table");
try{
Catalog.Exec(Function("Create") << "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C://New.mdb;");
}
catch(...)
{
file://problems - may be database already exist
}
file://Creating table
Table.Exec(PropertySet("Name") << "MyTable");
Columns=Table.Exec(PropertyGet("Columns"));
Columns.Exec(Function("Append") << "ItsFirstField" << adVarWChar << 20);
Columns.Exec(Function("Append") << "Next" << adInteger);
file://add table in database:
TablesDataBase=Catalog.Exec(PropertyGet("Tables"));
TablesDataBase.Exec(Function("Append") << Table);
TablesDataBase=Unassigned;
Columns=Unassigned;
Table=Unassigned;
Catalog=Unassigned;
}
Vladimir.
Technical Details
Message-ID:
<3e8145b7@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<3e804d72@newsgroups.borland.com> <3e808207$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10698b,1c113bcee69b4125 X-Google-Attributes: gid10698b,public X-Google-ArrivalTime: 2003-03-25 22:39:07 PST From: "guba" <admin@coka.co.yu> Newsgroups: borland.public.cppbuilder.database.ado References: <3e804d72@newsgroups.borland.com> <3e808207$1@newsgroups.borland.com> Subject: Re: How can I create Access table? Date: Wed, 26 Mar 2003 07:22:49 +0100 Lines: 68 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2919.6700 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700 NNTP-Posting-Host: 62.108.118.178 Message-ID: <3e8145b7@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1048659383 62.108.118.178 (25 Mar 2003 22:16:23 -0800) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail