🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Create a new table

#2317
From: Viatcheslav V. Vassiliev
Date: Mon, 18 Aug 2003 09:51
33 lines
2114 bytes
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: <3f40a28b$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-01!sn-xit-08!supernews.com!216.170.153.135.MISMATCH!tdsnet-transit!newspeer.tds.net!newsfeed.online.be!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>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10698b,5ff793e5206e9a54
X-Google-Attributes: gid10698b,public
X-Google-ArrivalTime: 2003-08-18 03:10:22 PST
From: "Viatcheslav V. Vassiliev" <support@oledbdirect.com>
Newsgroups: borland.public.cppbuilder.database.ado
References: <3f3fde36$1@newsgroups.borland.com> <3f407796$1@newsgroups.borland.com> <3f408401$1@newsgroups.borland.com>
Subject: Re: Create a new table
Date: Mon, 18 Aug 2003 13:51:27 +0400
Lines: 35
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
NNTP-Posting-Host: 213.247.201.57
Message-ID: <3f40a28b$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1061200523 213.247.201.57 (18 Aug 2003 02:55:23 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-01!sn-xit-08!supernews.com!216.170.153.135.MISMATCH!tdsnet-transit!newspeer.tds.net!newsfeed.online.be!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail