Article View: borland.public.cppbuilder.database.ado
Article #1003Re: Renaming Table
From: M.Leister
Date: Tue, 30 Nov 2004 10:28
Date: Tue, 30 Nov 2004 10:28
77 lines
3644 bytes
3644 bytes
AlexB wrote:
> M.Leister wrote:
>
>> I was trying yesterday to find a solution on how to rename a table in
>> either MsAccess, or Paradox or even DBASE using TADO... components.
>
> > Could someone give a hint on how to do it programatically?
>
> Searching for MSDN... Result:
>
> HOWTO: Change an Access Table Name Programmatically (Q291017)
> --------------------
> SUMMARY
> There are several ways to change a Microsoft Access table name in a
> Visual Basic application, some of which include the use of SQL, OLE
> automation, or Microsoft ActiveX Data Objects Extensions for Data
> Definition Language and Security (ADOX). The simplest method is to use
> ADOX to rename a table.
>
> MORE INFORMATION
> To use a Visual Basic 6.0 project to change an Access table name
> programmatically by using ADOX, do the following:
>
> Open a new Standard EXE project in Visual Basic. Form1 is created by
> default.
>
> On the Project menu, click to select References, and then add references
> to Microsoft ActiveX data object 2.x library and Microsoft ADO Ext. 2.x
> for DDL and Security.
>
> Paste the following code into the form load event:
>
> Dim cn As ADODB.Connection
> Dim t As Table
>
> Set cn = New ADODB.Connection
> cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;data Source=C:\biblio.mdb"
> Dim cat As ADOX.Catalog
> Set cat = New ADOX.Catalog
> Set cat.ActiveConnection = cn
> cat.Tables("Authors").Name = "Authors2" // rename
>
> 'Iterate through the tables collection
> For Each t In cat.Tables
> If t.Name = "Authors2" Then
> Debug.Print t.DateModified
> End If
> Next
>
> cn.Close
> Set cn = Nothing
> -------------------------
> i.e. you can use ADOX.
> How to start with ADOX:
> http://delphi.about.com/od/database/l/aa072401a.htm
> -------------------------
> AlexB.
>
Hello Alex.
Your hint seems to be valuable, but I couldn't get it working. I didn't
import "Microsoft ActiveX data object 2.x", since I have the ADO
components package already installed. Nevertheless I had to install
"Microsoft ADO Ext. 2.7". When trying to use your code, I couldn't
manage the following attributions
> Set cat.ActiveConnection = cn
> cat.Tables("Authors").Name = "Authors2" // rename
The Catalog class (TADOXCatalog) have neither "ActiveConnection" member
and nor "Tables" method that satisfies the syntax you've described. Do
you know what I'm doing wrong?
Thanks again,
Marcelo Leister.
Technical Details
Message-ID:
<41ac4b32$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!news2.euro.net!216.196.110.149.MISMATCH!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<41ac2787$1@newsgroups.borland.com> <41ac3057@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10698b,d9e78c2e0d78555b X-Google-Attributes: gid10698b,public X-Google-Language: ENGLISH,ASCII-7-bit Date: Tue, 30 Nov 2004 11:28:02 +0100 From: "M.Leister" <marceloleister@yahoo.com> User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5) Gecko/20031007 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: borland.public.cppbuilder.database.ado Subject: Re: Renaming Table References: <41ac2787$1@newsgroups.borland.com> <41ac3057@newsgroups.borland.com> In-Reply-To: <41ac3057@newsgroups.borland.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 195.65.184.250 Message-ID: <41ac4b32$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1101810482 195.65.184.250 (30 Nov 2004 02:28:02 -0700) Lines: 80 Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!news2.euro.net!216.196.110.149.MISMATCH!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail