Article View: borland.public.cppbuilder.database.ado
Article #2105Re: How to use ADOX to create tables and columns
From: Mike Crapo
Date: Wed, 05 Nov 2003 18:12
Date: Wed, 05 Nov 2003 18:12
61 lines
2728 bytes
2728 bytes
Steve This code will create a new table within a database. #include <ADODB.hpp> ADOConnection = new TADOConnection(0); ADOConnection->LoginPrompt = false; ADOConnection->Provider = "Microsoft.Jet.OLEDB.4.0"; ADOConnection->ConnectionString = "Data Source=c:\\DB.mdb;Persist Security Info=False"; ADOConnection->Open(); TADOCommand *Cmd = new TADOCommand(0); Cmd->CommandText = "CREATE TABLE TWhatever ([ID] AutoIncrement NOT NULL, [Info1] Memo NULL, [Info2] Memo NULL, [SomeNum] Integer)"; Cmd->Connection = ADOConnection; Cmd->Execute(); delete Cmd; ADOConnection->Close(); delete ADOConnection; This code will create a new column within a table #include <ADODB.hpp> ADOConnection = new TADOConnection(0); ADOConnection->LoginPrompt = false; ADOConnection->Provider = "Microsoft.Jet.OLEDB.4.0"; ADOConnection->ConnectionString = "Data Source=c:\\DB.mdb;Persist Security Info=False"; ADOConnection->Open(); TADOCommand *Cmd = new TADOCommand(0); Cmd->CommandText = "ALTER TABLE TWhatever ADD COLUMN [SomeNum2] Integer"; Cmd->Connection = ADOConnection; Cmd->Execute(); delete Cmd; ADOConnection->Close(); delete ADOConnection; Hope that helps. Mike On Wed, 5 Nov 2003 10:49:53 -0100, "Stefano" <p.bianchi@tin.it> wrote: >Hi Mike! > >> Why are you using ADOX to create your tables and fields, when you can >> use a SQL query to do the same?? > >Can you should please show same sample using SQL ? > >It's possible to do the same (creating a new database, tables ect.) using >ADO component (from C++ builder ADO component palette) via SQL command, >without the use of TADOXCatalog, TADOXTable etc ? > >Thanks in advance! >Steve >
Technical Details
Message-ID:
<b3fiqvodj799valc56sbglm2b77stl722v@4ax.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!small1.nntp.aus1.giganews.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<3fa6817b@newsgroups.borland.com> <hkifqv0hhacamvcupu5b3g7jkv82afls1m@4ax.com> <3fa8c808@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10698b,fd40af455f71879d X-Google-Attributes: gid10698b,public X-Google-ArrivalTime: 2003-11-05 10:28:56 PST From: Mike Crapo <> Newsgroups: borland.public.cppbuilder.database.ado Subject: Re: How to use ADOX to create tables and columns Date: Wed, 05 Nov 2003 12:12:31 -0600 Message-ID: <b3fiqvodj799valc56sbglm2b77stl722v@4ax.com> References: <3fa6817b@newsgroups.borland.com> <hkifqv0hhacamvcupu5b3g7jkv82afls1m@4ax.com> <3fa8c808@newsgroups.borland.com> X-Newsreader: Forte Agent 1.93/32.576 English (American) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 208.178.101.226 X-Trace: newsgroups.borland.com 1068056152 208.178.101.226 (5 Nov 2003 10:15:52 -0700) Lines: 62 Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!small1.nntp.aus1.giganews.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail