Article View: borland.public.cppbuilder.database.ado
Article #2323Re: Create a new table
From: Lee
Date: Wed, 20 Aug 2003 10:13
Date: Wed, 20 Aug 2003 10:13
136 lines
5407 bytes
5407 bytes
I still could not get your method to work, so I beat my head on the keyboard
all day and most of the night and came up with this.
DataModule->ADOConnection->Open();
DataModule->ADOQuery->SQL->Text = "CREATE TABLE LeeTest";
DataModule->ADOQuery->ExecSQL();
and it works for just creating a table with no data, that is next.
again thank you so much for you assistance. like I said I gave me a
direction to go
Lee
"Lee" <gobroski@elltel.net> wrote in message
news:3f425bdc@newsgroups.borland.com...
> Hello,
>
> Thank you for your time,
> I will give that a try today and let you know
>
> Lee
>
>
> "Viatcheslav V. Vassiliev" <support@oledbdirect.com> wrote in message
> news:3f41f9ca$1@newsgroups.borland.com...
> > In BCB6 this looks as:
> >
> > #include <ADODB_tlb.h>
> > #include <ADOX_tlb.h>
> >
> > void __fastcall TForm1::Button1Click(TObject *Sender)
> > {
> > //Database file
> > WideString db = "C:\\Temp\\Test.mdb";
> > if (FileExists(db)) DeleteFile(db);
> >
> > //Connection string
> > WideString strConn = WideString("Provider=Microsoft.Jet.OLEDB.4.0;") +
> > WideString("Data Source=") + db;
> >
> > {
> > //Create database
> > CatalogPtr cat = CoCatalog::Create();
> > cat->Create(strConn);
> > }
> >
> > //Open connection
> > ConnectionPtr conn = CoConnection::Create();
> > conn->Open(strConn.c_bstr(), WideString("").c_bstr(),
> > WideString("").c_bstr(), -1);
> >
> > tagVARIANT RecAffected;
> > RecAffected.vt = VT_I4;
> > RecAffected.intVal = 0;
> >
> > //Create table - here you can execute any SQL command
> > conn->Execute(WideString("Create table [MyTable] ([Col1] Int Primary
Key,
> > [Col2] VarChar(15))").c_bstr(),
> > &RecAffected, adExecuteNoRecords);
> > }
> >
> > If you are using BCB5 - be sure to delete all functions with
GhostMethod_
> in
> > name from imported type libraries.
> >
> > ----------------------------------------------------------------
> > Regards,
> > Viatcheslav V. Vassiliev
> > http://www.oledbdirect.com
> > The fastest way to access MS SQL Server, MS Jet (MS Access)
> > and Interbase (through OLEDB) databases.
> >
> > "Lee" <gobroski@elltel.net> �������/�������� � �������� ���������:
> > news:3f41bf11@newsgroups.borland.com...
> > > Hello,
> > >
> > > I see that this is exactly what I need, but I am unsure on how to
> > implement
> > > the code to get the results that I desire.
> > >
> > > Thank you for your help though... At least I have a map, with a
> > > destination.
> > >
> > > Lee
> > >
> > >
> > > "Viatcheslav V. Vassiliev" <support@oledbdirect.com> wrote in message
> > > news:3f40a28b$1@newsgroups.borland.com...
> > > > You are using OleVariant to work with Com object and I prefere to
use
> > > > imported type library. So I will show code in JScript - you should
> have
> > no
> > > > problems converting it to C++:
> > > >
> > > > //Database file
> > > > var db = "C:\\Temp\\Test.mdb";
> > > > //Connection string
> > > > var strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" +
> > > > "Data Source=" + db;
> > > >
> > > > //Create database
> > > > var cat = new ActiveXObject("ADOX.Catalog");
> > > > cat.Create(strConn);
> > > > cat = null;
> > > >
> > > > //Open connection
> > > > var conn = new ActiveXObject("ADODB.Connection");
> > > > conn.Open(strConn, "", "", -1);
> > > >
> > > > //SQL DDL command returns no recordset, this will optimize execute
> > method
> > > > var adExecuteNoRecords = 0x80;
> > > >
> > > > //Create table - here you can execute any SQL command
> > > > conn.Execute("Create table [MyTable] ([Col1] Int Primary Key, [Col2]
> > > > VarChar(15))",
> > > > null, adExecuteNoRecords);
> > > >
> > > > ----------------------------------------------------------------
> > > > Regards,
> > > > Viatcheslav V. Vassiliev
> > > > http://www.oledbdirect.com
> > > > The fastest way to access MS SQL Server, MS Jet (MS Access)
> > > > and Interbase (through OLEDB) databases.
> > > >
> > > >
> > >
> > >
> >
> >
>
>
Technical Details
Message-ID:
<3f4349db@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-09!supernews.com!newsfeed.news2me.com!elnk-nf2-pas!newsfeed.earthlink.net!news.astraweb.com!news-small.astraweb.com!news-out.spamkiller.net!propagator2-maxim!news-in.superfeed.net!newsfeed01.tsnz.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<3f3fde36$1@newsgroups.borland.com> <3f407796$1@newsgroups.borland.com> <3f408401$1@newsgroups.borland.com> <3f40a28b$1@newsgroups.borland.com> <3f41bf11@newsgroups.borland.com> <3f41f9ca$1@newsgroups.borland.com> <3f425bdc@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: 10698b,5ff793e5206e9a54 X-Google-Attributes: gid10698b,public X-Google-ArrivalTime: 2003-08-20 03:32:35 PST From: "Lee" <gobroski@elltel.net> Newsgroups: borland.public.cppbuilder.database.ado References: <3f3fde36$1@newsgroups.borland.com> <3f407796$1@newsgroups.borland.com> <3f408401$1@newsgroups.borland.com> <3f40a28b$1@newsgroups.borland.com> <3f41bf11@newsgroups.borland.com> <3f41f9ca$1@newsgroups.borland.com> <3f425bdc@newsgroups.borland.com> Subject: Re: Create a new table Date: Wed, 20 Aug 2003 03:13:56 -0700 Lines: 138 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: 12.18.161.26 Message-ID: <3f4349db@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1061374427 12.18.161.26 (20 Aug 2003 03:13:47 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-09!supernews.com!newsfeed.news2me.com!elnk-nf2-pas!newsfeed.earthlink.net!news.astraweb.com!news-small.astraweb.com!news-out.spamkiller.net!propagator2-maxim!news-in.superfeed.net!newsfeed01.tsnz.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail