🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.database.ado
Article #1506

Re: Create new database problem

#1506
From: Viatcheslav V. Vassiliev
Date: Fri, 23 Apr 2004 19:34
92 lines
4413 bytes
I would recommend to use ADO and SQL to create tables, indeces, foreign keys
etc. - for most cases it is enough. For foreigh key use:

CREATE TABLE Orders (ID INTEGER PRIMARY KEY, ClientID INTEGER, Notes NCHAR
VARYING (255), CONSTRAINT KeyClientID FOREIGN KEY (ClientID) REFERENCES
Clients ON UPDATE CASCADE ON DELETE CASCADE)

If you have MS Office, look

C:\Program Files\Common Files\Microsoft Shared\OFFICEXX\XXXX\JETSQL40.CHM

(XX are numbers, may differ for different office and language)

for details on Jet SQL. In MSDN search for "Jet SQL" and check "Search in
titles only". You will find 3 articles - "Intermediate/Fundamental/Advanced
Microsoft Jet SQL for Access 2000".

>Catch-all exception

All exceptions from COM objects are EOleException. Look at error code -
0x80040E17 - DB_E_DUPLICATEDATASOURCE - "Data source object could not be
created because the named data source already exists". Look oledberr.h for
more error codes.

//------------------------------------------
Regards,
Vassiliev V. V.
http://www.managed-vcl.com - using .Net objects in Delphi for Win32 +
ADO.Net
http://www.oledbdirect.com - The fastest way to access MS SQL Server,
MS Jet (Access) and Interbase (through OLEDB)

"Martin Moeller" <martin.moeller@moema.it> �������/�������� � ��������
���������: news:40895c5a@newsgroups.borland.com...
> Vassiliev, thank you very much.
>
> I've tested your code & it works fine.
>
> void __fastcall TfrmMain::btnCreateClick(TObject *Sender)
> {
>  WideString strConn = "Provider=Microsoft.Jet.OLEDB.4.0;"
>   "Data Source=" + ExtractFilePath(ParamStr(0)) + "test.mdb";
>
>  Adox_tlb::TCOM_Catalog cat = CoCatalog::Create();
>  cat->Create(strConn.c_bstr());
>  cat.Release();
> }
>
>
> Then I also debugged mine and found a few intersting anomalities about
that
> exception:
>
> ---------------------------
> HRCHECK:
> ---------------------------
> (this->Create(ConnectString, (VARIANT*)&Connection)) Error: 80040E17
> (-2147217897) @ c:\programmi\borland\cbuilder6\Imports\ADOX_TLB.h/487
> Press [Y]es to terminate, [N]o to continue and [C]ancel to Debug
> ---------------------------
> S�   No   Annulla
> ---------------------------
>
> On my string he could not manage the root-without-drive definition. It's a
> long time ago, but I think it was a legal DOS statement.
>
>     Data Source=.\\New.mdb";       fails
>     Data Source=C:\\New.mdb";    works
>
> Further this exception seems to be a catch-all type. It is produced also
if
> the file already exists, i.e. in our case pressing the button twice.
>
> I've been working to create Tables and primary keys, as well as foreign
> keys, in which case the table declaration sequence must be consistent of
> course.
>
> Trying to create a foreign key via ASSERTION makes an error. Can you do it
> at all in MS ACCESS? Or is there another way to specify foreign keys
outside
> the table?
>
>   ExecuteString=  "CREATE ASSERTION peppo \
>                    FOREIGN KEY [ActiveNow](ETA) REFERENCES
> [Tab2](ETA_PRKEY))";
>
> Where do u find a list of implemented comands?
>
> Tks again, Martin
>
>
>
Technical Details
Message-ID: <40896fcc$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <4087d2f4@newsgroups.borland.com> <4087ef31$1@newsgroups.borland.com> <4087ff9c$1@newsgroups.borland.com> <40881473$1@newsgroups.borland.com> <40881b61$1@newsgroups.borland.com> <4089186f@newsgroups.borland.com> <408924bc@newsgroups.borland.com> <40895c5a@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: 10698b,270202afc138267d
X-Google-Attributes: gid10698b,public
X-Google-ArrivalTime: 2004-04-23 12:40:03 PST
From: "Viatcheslav V. Vassiliev" <support@oledbdirect.com>
Newsgroups: borland.public.cppbuilder.database.ado
References: <4087d2f4@newsgroups.borland.com> <4087ef31$1@newsgroups.borland.com> <4087ff9c$1@newsgroups.borland.com> <40881473$1@newsgroups.borland.com> <40881b61$1@newsgroups.borland.com> <4089186f@newsgroups.borland.com> <408924bc@newsgroups.borland.com> <40895c5a@newsgroups.borland.com>
Subject: Re: Create new database problem
Date: Fri, 23 Apr 2004 23:34:39 +0400
Lines: 94
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: <40896fcc$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1082748876 213.234.218.42 (23 Apr 2004 12:34:36 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail