Article View: borland.public.cppbuilder.database.ado
Article #1509Re: Create new database problem
From: Viatcheslav V. Vassiliev
Date: Wed, 28 Apr 2004 13:56
Date: Wed, 28 Apr 2004 13:56
113 lines
5155 bytes
5155 bytes
>What is wrong? I'm closing the connection.
You do but ADO does not - this is named connection pooling. If you will open
connection again, ADO will provide you existing (cached) one. Sometimes
adding "OLE DB Services=-2" to connection string (to ADOConnection, not to
ADOX catalog) could help, sometimes not.
//------------------------------------------
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:408eb23f$1@newsgroups.borland.com...
>
> Hi Vassiliev,
>
> > 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".
> >
>
> The MS-Office help path is a deadlock (installation of italian version is
> completelly different & the help opened within office has all statements
> translated as used in application wizards and thereby not good to form sql
> statements).
>
> The JetSQL search fails, but searching directly "Microsoft Jet SQL for
> Access 2000" leads to those 3 articles & the *are* a very usefull
> documentation.
> Working through them.
>
> I have a file open problem. My code deletes & creates a new database file.
> It works fine only once per debugg session; the second time it fails as
the
> file is already open. What is wrong? I'm closing the connection.
>
>
> void __fastcall TForm1::Button1Click(TObject *Sender)
> {
>
> AnsiString FileName="..\\MsAccessTestFile.mdb";
> if(FileExists(FileName)==true)
> DeleteFile(FileName);
>
> // create new file
> WideString ConnStr="Provider=Microsoft.Jet.OLEDB.4.0;"
> "Data Source=" + FileName;
> Adox_tlb::TCOM_Catalog cat = CoCatalog::Create();
> cat->Create(ConnStr.c_bstr());
> cat.Release();
>
>
> // Pass to TAdoConnection component
>
> ADOConnection->ConnectionString=ConnStr.c_bstr();
> ADOConnection->LoginPrompt=false;
> ADOConnection->Mode=cmShareDenyNone;
> ADOConnection->Provider="Microsoft.Jet.OLEDB.4.0";
> ADOConnection->Open();
>
>
> // creates Table Micro
> WideString ExecuteString="";
> ExecuteString= "CREATE TABLE Micro"
> "([PRKEY] AutoIncrement NOT NULL, \
> [MicID] Text(16) NOT NULL, \
> [Active] DATETIME NULL, \
> [Line] Numeric NULL, \
> [NetID] Numeric NULL, \
> [ErrSt] Numeric NULL, \
> [EepFile] NCHAR (20) NULL, \
> [Notes] Memo, \
> PRIMARY KEY (PRKEY) \
> )";
> ADOConnection->Execute(ExecuteString.c_bstr());
>
> ExecuteString= "CREATE TABLE Lines" \
> ( [VerDate] DATETIME NOT NULL, \
> [Line] Numeric NOT NULL, \
> [ComPort] NCHAR (5) NULL, \
> [BaudRate] Numeric NULL, \
> [Type] NCHAR (6) NULL, \
> [Notes] Memo, \
> PRIMARY KEY (VerDate,Line) \
> )";
>
> ADOConnection->Execute(ExecuteString.c_bstr());
>
>
> ExecuteString= "CREATE INDEX idxMicId"
> "ON Micro (MicID DESC)" ;
>
> ADOConnection->Execute(ExecuteString.c_bstr());
>
> ADOConnection->Close();
>
> }
>
>
> Tks, Martin
>
>
Technical Details
Message-ID:
<408fb818@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.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-mailReferences:
<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> <40896fcc$1@newsgroups.borland.com> <408eb23f$1@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-28 07:10:18 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> <40896fcc$1@newsgroups.borland.com> <408eb23f$1@newsgroups.borland.com> Subject: Re: Create new database problem Date: Wed, 28 Apr 2004 17:56:37 +0400 Lines: 115 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: <408fb818@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1083160600 213.234.218.42 (28 Apr 2004 06:56:40 -0700) Path: arc1-ca.pugleaf.net!archiver1.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