Article View: borland.public.cppbuilder.database.ado
Article #1002Re: Renaming Table
From: AlexB
Date: Tue, 30 Nov 2004 08:33
Date: Tue, 30 Nov 2004 08:33
55 lines
2791 bytes
2791 bytes
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.
Technical Details
Message-ID:
<41ac3057@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!prodigy.com!atl-c02.usenetserver.com!c03.atl99.usenetserver.com!news.usenetserver.com!news02.tsnz.net!newsfeed01.tsnz.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<41ac2787$1@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 14:33:23 +0600 From: AlexB <b.a.v@inbox.ru> User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.2) Gecko/20040804 Netscape/7.2 (ax) X-Accept-Language: ru, en-us, en MIME-Version: 1.0 Newsgroups: borland.public.cppbuilder.database.ado Subject: Re: Renaming Table References: <41ac2787$1@newsgroups.borland.com> In-Reply-To: <41ac2787$1@newsgroups.borland.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 212.192.185.54 Message-ID: <41ac3057@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1101803607 212.192.185.54 (30 Nov 2004 00:33:27 -0700) Lines: 56 Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!prodigy.com!atl-c02.usenetserver.com!c03.atl99.usenetserver.com!news.usenetserver.com!news02.tsnz.net!newsfeed01.tsnz.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail