🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Create a new table

#2321
From: Lee
Date: Tue, 19 Aug 2003 17:18
115 lines
4502 bytes
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: <3f425bdc@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!sn-xit-09!supernews.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
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>

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-19 10:43:09 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>
Subject: Re: Create a new table
Date: Tue, 19 Aug 2003 10:18:28 -0700
Lines: 117
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: <3f425bdc@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1061313500 12.18.161.26 (19 Aug 2003 10:18:20 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!sn-xit-09!supernews.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail