Article View: borland.public.cppbuilder.database.ado
Article #1975Re: How to use ADOX to link tables in MS Access
From: Viatcheslav V. Vassiliev
Date: Thu, 08 Jan 2004 15:40
Date: Thu, 08 Jan 2004 15:40
81 lines
3986 bytes
3986 bytes
This JScript should help you. Use TADOConnection->Execute() instead of
creating/deleting TADOCommands - your commands have no parameters.
Look for line breaks.
//-----------------------------------------------------------------
var connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=db_test.mdb";
var cat = new ActiveXObject("ADOX.Catalog");
cat.Create(connStr);
cat = null;
var conn = new ActiveXObject("ADODB.Connection");
conn.Open(connStr);
conn.Execute("CREATE TABLE [CatTable] ([ID] AutoIncrement NOT NULL
CONSTRAINT [PrimKey] PRIMARY KEY, [Nome] Text NULL)");
conn.Execute("CREATE TABLE [FotTable] ([ID] AutoIncrement NOT NULL
CONSTRAINT [PrimKey] PRIMARY KEY, [NomeFotog] Text NULL, " +
"[X] double NULL, [Y] double NULL)");
conn.Execute("CREATE TABLE [PtsTable] ([ID] AutoIncrement NOT NULL
CONSTRAINT [PrimKey] PRIMARY KEY, " +
"[IDCat] integer NOT NULL, [X] double NULL, [Y] double NULL, [Z] double
NULL, [SigmaX] double NULL, [SigmaY] double NULL, " +
"[SigmaZ] double NULL, [IDFotog] integer NULL, [Note] Text NULL, " +
"CONSTRAINT CatLink FOREIGN KEY ([IDCat]) REFERENCES [CatTable]([ID]), " +
"CONSTRAINT FotLink FOREIGN KEY ([IDFotog]) REFERENCES [FotTable]([ID]))");
conn.Close();
conn = null;
//-------------------------------------------------------------------
"Pat" <pat-rizioAGR@libero.it> ???????/???????? ? ???????? ?????????:
news:3ffd3f77@newsgroups.borland.com...
> Hi,
> looking past post I learn how to create a new table in a MS Access
> database, and I create 3 tables (named CatTable, FotTable, PtsTable) as
> the following:
>
> // Creation CatTable
> TADOCommand *Cmd1 = new TADOCommand(0);
> Cmd1->CommandText = "CREATE TABLE "+ CatTableName +" ([ID] AutoIncrement
> NOT NULL, [Nome] Text NULL)";
> Cmd1->Connection = ADOConnection;
> Cmd1->Execute();
> delete Cmd1;
>
> // Creation FotTable
> TADOCommand *Cmd2 = new TADOCommand(0);
> Cmd2->CommandText = "CREATE TABLE "+ FotTableName +" ([ID] AutoIncrement
> NOT NULL, [NomeFotog] Text NULL, [X] double NULL, [Y] double NULL)";
> Cmd2->Connection = ADOConnection;
> Cmd2->Execute();
> delete Cmd2;
>
> // Creation PtsTable
> TADOCommand *Cmd3 = new TADOCommand(0);
> Cmd3->CommandText = "CREATE TABLE "+ PtsTableName +" ([ID] AutoIncrement
> NOT NULL, [IDCat] integer NOT NULL, [X] double NULL, [Y] double NULL,
> [Z] double NULL, [SigmaX] double NULL, [SigmaY] double NULL, [SigmaZ]
> double NULL, [IDFotog] integer NULL, [Note] Text NULL)";
> Cmd3->Connection = ADOConnection;
> Cmd3->Execute();
> delete Cmd3;
>
> But now I have to link them.
> In particular:
> - in PtsTable the colomn [IDCat] must be link to colomn [ID] of CatTable
> - in PtsTable the colomn [IDFotog] must be link to colomn [ID] of FotTable
>
> How can I do this?
> How can I set the double's precision of the colomn in a table (for
> example colomn [X] in CatTable?
> And how can I set the table's primary key?
> If I create tables as seen before primary key is unset.
> Thanks a lot for answers
>
>
> --
> remove AGR for reply
>
Technical Details
Message-ID:
<3ffd7a14$2@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<3ffd3f77@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10698b,e3763118c208c643 X-Google-Attributes: gid10698b,public X-Google-ArrivalTime: 2004-01-08 07:46:49 PST From: "Viatcheslav V. Vassiliev" <support@oledbdirect.com> Newsgroups: borland.public.cppbuilder.database.ado References: <3ffd3f77@newsgroups.borland.com> Subject: Re: How to use ADOX to link tables in MS Access Date: Thu, 8 Jan 2004 18:40:38 +0300 Lines: 84 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 NNTP-Posting-Host: 213.234.218.42 Message-ID: <3ffd7a14$2@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1073576468 213.234.218.42 (8 Jan 2004 07:41:08 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail