how to rename a table with adodb 
Author Message
 how to rename a table with adodb

Hi,

i must rename a table at runtime.
Anybody know how i can do that?

I use ADODB and i think the old db provider 4.1 does not fully support ALTER
TABLE
It works only for columns not for table.
I try
"ALTER TABLE oldname TO newname"
-> Syntay Error
is there any ay else ?
thanx

holgi



Fri, 16 Apr 2004 17:42:42 GMT  
 how to rename a table with adodb
On Mon, 29 Oct 2001 10:42:42 +0100, "Holger Schr?der"

Quote:

>Hi,

>i must rename a table at runtime.
>Anybody know how i can do that?

>I use ADODB and i think the old db provider 4.1 does not fully support ALTER
>TABLE
>It works only for columns not for table.
>I try
>"ALTER TABLE oldname TO newname"
>-> Syntay Error
>is there any ay else ?

What database are you using?


Fri, 16 Apr 2004 19:50:13 GMT  
 how to rename a table with adodb

Have you tried ADOX ?

--
Gareth Jenkins
Jack Jack Two LTD

www.jackjack2.co.uk

| Hi,
|
| i must rename a table at runtime.
| Anybody know how i can do that?
|
| I use ADODB and i think the old db provider 4.1 does not fully support
ALTER
| TABLE
| It works only for columns not for table.
| I try
| "ALTER TABLE oldname TO newname"
| -> Syntay Error
| is there any ay else ?
| thanx
|
| holgi
|
|



Fri, 16 Apr 2004 20:07:26 GMT  
 how to rename a table with adodb
<Chris Donovan> schrieb im Newsbeitrag

Quote:
> On Mon, 29 Oct 2001 10:42:42 +0100, "Holger Schr?der"

> >Hi,

> >i must rename a table at runtime.
> >Anybody know how i can do that?

> >I use ADODB and i think the old db provider 4.1 does not fully support
ALTER
> >TABLE
> >It works only for columns not for table.
> >I try
> >"ALTER TABLE oldname TO newname"
> >-> Syntay Error
> >is there any ay else ?

> What database are you using?

access 2000


Fri, 16 Apr 2004 20:47:57 GMT  
 how to rename a table with adodb



Quote:

> Have you tried ADOX ?

> --
> Gareth Jenkins
> Jack Jack Two LTD

> www.jackjack2.co.uk

Is the name property of a table writeable?
Is there anywhere an example for rename a table with ADOX?


Fri, 16 Apr 2004 20:53:23 GMT  
 how to rename a table with adodb

The Name property is read/write for tables, i haven't seen an example to
rename a table, but the following is taken from the ADOX documentation
example for creating a table in an existing database:

Just make sure you've got a reference to msadox.dll in your project and you
should be able to adapt the following code pretty easily.

-----------
Sub CreateTable()

   Dim tbl As New Table
   Dim cat As New ADOX.Catalog

'Open the catalog.
   ' Open the Catalog.
   cat.ActiveConnection = _
      "Provider=Microsoft.Jet.OLEDB.4.0;" & _
      "Data Source=c:\Program Files\Microsoft Office\" & _
      "Office\Samples\Northwind.mdb;"

   tbl.Name = "MyTable"
   tbl.Columns.Append "Column1", adInteger
   tbl.Columns.Append "Column2", adInteger
   tbl.Columns.Append "Column3", adVarWChar, 50
   cat.Tables.Append tbl

End Sub
----

-- Gareth JenkinsJack Jack Two LTD

www.jackjack2.co.uk

|


| >
| > Have you tried ADOX ?
| >
| >
| >
| > --
| > Gareth Jenkins
| > Jack Jack Two LTD
| >
| > www.jackjack2.co.uk
| >
|
| Is the name property of a table writeable?
| Is there anywhere an example for rename a table with ADOX?
|
|



Fri, 16 Apr 2004 23:06:19 GMT  
 how to rename a table with adodb

Please ignore that last post, i just noticed, you can only change a table
name before it is appended to a collection. Unless there is some way to
remove the table from the collection and then add it back in ADOX may be out
of the question. Sorry.

--
Gareth Jenkins
Jack Jack Two LTD

www.jackjack2.co.uk

|
| The Name property is read/write for tables, i haven't seen an example to
| rename a table, but the following is taken from the ADOX documentation
| example for creating a table in an existing database:
|
| Just make sure you've got a reference to msadox.dll in your project and
you
| should be able to adapt the following code pretty easily.
|
| -----------
| Sub CreateTable()
|
|    Dim tbl As New Table
|    Dim cat As New ADOX.Catalog
|
| 'Open the catalog.
|    ' Open the Catalog.
|    cat.ActiveConnection = _
|       "Provider=Microsoft.Jet.OLEDB.4.0;" & _
|       "Data Source=c:\Program Files\Microsoft Office\" & _
|       "Office\Samples\Northwind.mdb;"
|
|    tbl.Name = "MyTable"
|    tbl.Columns.Append "Column1", adInteger
|    tbl.Columns.Append "Column2", adInteger
|    tbl.Columns.Append "Column3", adVarWChar, 50
|    cat.Tables.Append tbl
|
| End Sub
| ----
|
| -- Gareth JenkinsJack Jack Two LTD
|
| www.jackjack2.co.uk


| |


| | >
| | > Have you tried ADOX ?
| | >
| | >
| | >
| | > --
| | > Gareth Jenkins
| | > Jack Jack Two LTD
| | >
| | > www.jackjack2.co.uk
| | >
| |
| | Is the name property of a table writeable?
| | Is there anywhere an example for rename a table with ADOX?
| |
| |
|
|



Fri, 16 Apr 2004 23:15:19 GMT  
 how to rename a table with adodb
thanx for your help


Quote:

> Please ignore that last post, i just noticed, you can only change a table
> name before it is appended to a collection. Unless there is some way to
> remove the table from the collection and then add it back in ADOX may be
out
> of the question. Sorry.

> --
> Gareth Jenkins
> Jack Jack Two LTD

> www.jackjack2.co.uk


> |
> | The Name property is read/write for tables, i haven't seen an example to
> | rename a table, but the following is taken from the ADOX documentation
> | example for creating a table in an existing database:
> |
> | Just make sure you've got a reference to msadox.dll in your project and
> you
> | should be able to adapt the following code pretty easily.
> |
> | -----------
> | Sub CreateTable()
> |
> |    Dim tbl As New Table
> |    Dim cat As New ADOX.Catalog
> |
> | 'Open the catalog.
> |    ' Open the Catalog.
> |    cat.ActiveConnection = _
> |       "Provider=Microsoft.Jet.OLEDB.4.0;" & _
> |       "Data Source=c:\Program Files\Microsoft Office\" & _
> |       "Office\Samples\Northwind.mdb;"
> |
> |    tbl.Name = "MyTable"
> |    tbl.Columns.Append "Column1", adInteger
> |    tbl.Columns.Append "Column2", adInteger
> |    tbl.Columns.Append "Column3", adVarWChar, 50
> |    cat.Tables.Append tbl
> |
> | End Sub
> | ----
> |
> | -- Gareth JenkinsJack Jack Two LTD
> |
> | www.jackjack2.co.uk


> | |


> | | >
> | | > Have you tried ADOX ?
> | | >
> | | >
> | | >
> | | > --
> | | > Gareth Jenkins
> | | > Jack Jack Two LTD
> | | >
> | | > www.jackjack2.co.uk
> | | >
> | |
> | | Is the name property of a table writeable?
> | | Is there anywhere an example for rename a table with ADOX?
> | |
> | |
> |
> |



Fri, 16 Apr 2004 23:24:25 GMT  
 how to rename a table with adodb

The fact that the ADOX documentation claims you can't rename a table after
it's been appended annoyed me, so i set out to find another way... before i
did this i thought i better check... to my suprise you can do despite what
the documentation says, here's the following code i tested on a table with
data and it worked no problems at all:
----
Dim tbl As ADOX.Table
Dim cat As New ADOX.Catalog

cat.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
      "Data Source=c:\temp\nametest.mdb;"

Set tbl = cat.Tables("newtable")

tbl.Name = "testname"

Set tbl = Nothing
Set cat = Nothing
-----

Hope this helps.

--
Gareth Jenkins
Jack Jack Two LTD

www.jackjack2.co.uk

| thanx for your help


| >
| > Please ignore that last post, i just noticed, you can only change a
table
| > name before it is appended to a collection. Unless there is some way to
| > remove the table from the collection and then add it back in ADOX may be
| out
| > of the question. Sorry.
| >
| >
| >
| > --
| > Gareth Jenkins
| > Jack Jack Two LTD
| >
| > www.jackjack2.co.uk


| > |
| > | The Name property is read/write for tables, i haven't seen an example
to
| > | rename a table, but the following is taken from the ADOX documentation
| > | example for creating a table in an existing database:
| > |
| > | Just make sure you've got a reference to msadox.dll in your project
and
| > you
| > | should be able to adapt the following code pretty easily.
| > |
| > | -----------
| > | Sub CreateTable()
| > |
| > |    Dim tbl As New Table
| > |    Dim cat As New ADOX.Catalog
| > |
| > | 'Open the catalog.
| > |    ' Open the Catalog.
| > |    cat.ActiveConnection = _
| > |       "Provider=Microsoft.Jet.OLEDB.4.0;" & _
| > |       "Data Source=c:\Program Files\Microsoft Office\" & _
| > |       "Office\Samples\Northwind.mdb;"
| > |
| > |    tbl.Name = "MyTable"
| > |    tbl.Columns.Append "Column1", adInteger
| > |    tbl.Columns.Append "Column2", adInteger
| > |    tbl.Columns.Append "Column3", adVarWChar, 50
| > |    cat.Tables.Append tbl
| > |
| > | End Sub
| > | ----
| > |
| > | -- Gareth JenkinsJack Jack Two LTD
| > |
| > | www.jackjack2.co.uk


| > | |


| > | | >
| > | | > Have you tried ADOX ?
| > | | >
| > | | >
| > | | >
| > | | > --
| > | | > Gareth Jenkins
| > | | > Jack Jack Two LTD
| > | | >
| > | | > www.jackjack2.co.uk
| > | | >
| > | |
| > | | Is the name property of a table writeable?
| > | | Is there anywhere an example for rename a table with ADOX?
| > | |
| > | |
| > |
| > |
| >
| >
|
|



Fri, 16 Apr 2004 23:32:13 GMT  
 how to rename a table with adodb
i will test it tonite



Quote:

> The fact that the ADOX documentation claims you can't rename a table after
> it's been appended annoyed me, so i set out to find another way... before
i
> did this i thought i better check... to my suprise you can do despite what
> the documentation says, here's the following code i tested on a table with
> data and it worked no problems at all:
> ----
> Dim tbl As ADOX.Table
> Dim cat As New ADOX.Catalog

> cat.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
>       "Data Source=c:\temp\nametest.mdb;"

> Set tbl = cat.Tables("newtable")

> tbl.Name = "testname"

> Set tbl = Nothing
> Set cat = Nothing
> -----

> Hope this helps.

> --
> Gareth Jenkins
> Jack Jack Two LTD

> www.jackjack2.co.uk


> | thanx for your help


> | >
> | > Please ignore that last post, i just noticed, you can only change a
> table
> | > name before it is appended to a collection. Unless there is some way
to
> | > remove the table from the collection and then add it back in ADOX may
be
> | out
> | > of the question. Sorry.
> | >
> | >
> | >
> | > --
> | > Gareth Jenkins
> | > Jack Jack Two LTD
> | >
> | > www.jackjack2.co.uk


> | > |
> | > | The Name property is read/write for tables, i haven't seen an
example
> to
> | > | rename a table, but the following is taken from the ADOX
documentation
> | > | example for creating a table in an existing database:
> | > |
> | > | Just make sure you've got a reference to msadox.dll in your project
> and
> | > you
> | > | should be able to adapt the following code pretty easily.
> | > |
> | > | -----------
> | > | Sub CreateTable()
> | > |
> | > |    Dim tbl As New Table
> | > |    Dim cat As New ADOX.Catalog
> | > |
> | > | 'Open the catalog.
> | > |    ' Open the Catalog.
> | > |    cat.ActiveConnection = _
> | > |       "Provider=Microsoft.Jet.OLEDB.4.0;" & _
> | > |       "Data Source=c:\Program Files\Microsoft Office\" & _
> | > |       "Office\Samples\Northwind.mdb;"
> | > |
> | > |    tbl.Name = "MyTable"
> | > |    tbl.Columns.Append "Column1", adInteger
> | > |    tbl.Columns.Append "Column2", adInteger
> | > |    tbl.Columns.Append "Column3", adVarWChar, 50
> | > |    cat.Tables.Append tbl
> | > |
> | > | End Sub
> | > | ----
> | > |
> | > | -- Gareth JenkinsJack Jack Two LTD
> | > |
> | > | www.jackjack2.co.uk


> | > | |


> | > | | >
> | > | | > Have you tried ADOX ?
> | > | | >
> | > | | >
> | > | | >
> | > | | > --
> | > | | > Gareth Jenkins
> | > | | > Jack Jack Two LTD
> | > | | >
> | > | | > www.jackjack2.co.uk
> | > | | >
> | > | |
> | > | | Is the name property of a table writeable?
> | > | | Is there anywhere an example for rename a table with ADOX?
> | > | |
> | > | |
> | > |
> | > |
> | >
> | >
> |
> |



Sat, 17 Apr 2004 00:44:44 GMT  
 how to rename a table with adodb
Well, looks like you guys got this sorted out before I got back to the
newsgoup. :)

Gareth is right, you can rename a table in Access using ADOX, just
change the table name property.

This does not work with most other database, however. If you're using
MSSQL, for example, you must execute a stored procedure. If you're
using Excel, you must use Excel Automation (ugh). Some other DB's
(including Oracle and MySQL, I believe) support the Alter Table syntax
that Holger first was using (but not Access nor MSSQL).

Chris

On Mon, 29 Oct 2001 17:44:44 +0100, "Holger Schr?der"

Quote:

>i will test it tonite



>> The fact that the ADOX documentation claims you can't rename a table after
>> it's been appended annoyed me, so i set out to find another way... before
>i
>> did this i thought i better check... to my suprise you can do despite what
>> the documentation says, here's the following code i tested on a table with
>> data and it worked no problems at all:
>> ----
>> Dim tbl As ADOX.Table
>> Dim cat As New ADOX.Catalog

>> cat.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
>>       "Data Source=c:\temp\nametest.mdb;"

>> Set tbl = cat.Tables("newtable")

>> tbl.Name = "testname"

>> Set tbl = Nothing
>> Set cat = Nothing
>> -----

>> Hope this helps.

>> --
>> Gareth Jenkins
>> Jack Jack Two LTD

>> www.jackjack2.co.uk


>> | thanx for your help


>> | >
>> | > Please ignore that last post, i just noticed, you can only change a
>> table
>> | > name before it is appended to a collection. Unless there is some way
>to
>> | > remove the table from the collection and then add it back in ADOX may
>be
>> | out
>> | > of the question. Sorry.
>> | >
>> | >
>> | >
>> | > --
>> | > Gareth Jenkins
>> | > Jack Jack Two LTD
>> | >
>> | > www.jackjack2.co.uk


>> | > |
>> | > | The Name property is read/write for tables, i haven't seen an
>example
>> to
>> | > | rename a table, but the following is taken from the ADOX
>documentation
>> | > | example for creating a table in an existing database:
>> | > |
>> | > | Just make sure you've got a reference to msadox.dll in your project
>> and
>> | > you
>> | > | should be able to adapt the following code pretty easily.
>> | > |
>> | > | -----------
>> | > | Sub CreateTable()
>> | > |
>> | > |    Dim tbl As New Table
>> | > |    Dim cat As New ADOX.Catalog
>> | > |
>> | > | 'Open the catalog.
>> | > |    ' Open the Catalog.
>> | > |    cat.ActiveConnection = _
>> | > |       "Provider=Microsoft.Jet.OLEDB.4.0;" & _
>> | > |       "Data Source=c:\Program Files\Microsoft Office\" & _
>> | > |       "Office\Samples\Northwind.mdb;"
>> | > |
>> | > |    tbl.Name = "MyTable"
>> | > |    tbl.Columns.Append "Column1", adInteger
>> | > |    tbl.Columns.Append "Column2", adInteger
>> | > |    tbl.Columns.Append "Column3", adVarWChar, 50
>> | > |    cat.Tables.Append tbl
>> | > |
>> | > | End Sub
>> | > | ----
>> | > |
>> | > | -- Gareth JenkinsJack Jack Two LTD
>> | > |
>> | > | www.jackjack2.co.uk


>> | > | |


>> | > | | >
>> | > | | > Have you tried ADOX ?
>> | > | | >
>> | > | | >
>> | > | | >
>> | > | | > --
>> | > | | > Gareth Jenkins
>> | > | | > Jack Jack Two LTD
>> | > | | >
>> | > | | > www.jackjack2.co.uk
>> | > | | >
>> | > | |
>> | > | | Is the name property of a table writeable?
>> | > | | Is there anywhere an example for rename a table with ADOX?
>> | > | |
>> | > | |
>> | > |
>> | > |
>> | >
>> | >
>> |
>> |



Sat, 17 Apr 2004 06:26:03 GMT  
 how to rename a table with adodb
thank you for this information,
the access DB is only for prototyping.
Later we will use an Oracle and a MSSQL DB
I like it to implement different ways :)

<Chris Donovan> schrieb im Newsbeitrag

Quote:
> Well, looks like you guys got this sorted out before I got back to the
> newsgoup. :)

> Gareth is right, you can rename a table in Access using ADOX, just
> change the table name property.

> This does not work with most other database, however. If you're using
> MSSQL, for example, you must execute a stored procedure. If you're
> using Excel, you must use Excel Automation (ugh). Some other DB's
> (including Oracle and MySQL, I believe) support the Alter Table syntax
> that Holger first was using (but not Access nor MSSQL).

> Chris

> On Mon, 29 Oct 2001 17:44:44 +0100, "Holger Schr?der"

> >i will test it tonite



> >> The fact that the ADOX documentation claims you can't rename a table
after
> >> it's been appended annoyed me, so i set out to find another way...
before
> >i
> >> did this i thought i better check... to my suprise you can do despite
what
> >> the documentation says, here's the following code i tested on a table
with
> >> data and it worked no problems at all:
> >> ----
> >> Dim tbl As ADOX.Table
> >> Dim cat As New ADOX.Catalog

> >> cat.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
> >>       "Data Source=c:\temp\nametest.mdb;"

> >> Set tbl = cat.Tables("newtable")

> >> tbl.Name = "testname"

> >> Set tbl = Nothing
> >> Set cat = Nothing
> >> -----

> >> Hope this helps.

> >> --
> >> Gareth Jenkins
> >> Jack Jack Two LTD

> >> www.jackjack2.co.uk


> >> | thanx for your help


> >> | >
> >> | > Please ignore that last post, i just noticed, you can only change a
> >> table
> >> | > name before it is appended to a collection. Unless there is some
way
> >to
> >> | > remove the table from the collection and then add it back in ADOX
may
> >be
> >> | out
> >> | > of the question. Sorry.
> >> | >
> >> | >
> >> | >
> >> | > --
> >> | > Gareth Jenkins
> >> | > Jack Jack Two LTD
> >> | >
> >> | > www.jackjack2.co.uk


> >> | > |
> >> | > | The Name property is read/write for tables, i haven't seen an
> >example
> >> to
> >> | > | rename a table, but the following is taken from the ADOX
> >documentation
> >> | > | example for creating a table in an existing database:
> >> | > |
> >> | > | Just make sure you've got a reference to msadox.dll in your
project
> >> and
> >> | > you
> >> | > | should be able to adapt the following code pretty easily.
> >> | > |
> >> | > | -----------
> >> | > | Sub CreateTable()
> >> | > |
> >> | > |    Dim tbl As New Table
> >> | > |    Dim cat As New ADOX.Catalog
> >> | > |
> >> | > | 'Open the catalog.
> >> | > |    ' Open the Catalog.
> >> | > |    cat.ActiveConnection = _
> >> | > |       "Provider=Microsoft.Jet.OLEDB.4.0;" & _
> >> | > |       "Data Source=c:\Program Files\Microsoft Office\" & _
> >> | > |       "Office\Samples\Northwind.mdb;"
> >> | > |
> >> | > |    tbl.Name = "MyTable"
> >> | > |    tbl.Columns.Append "Column1", adInteger
> >> | > |    tbl.Columns.Append "Column2", adInteger
> >> | > |    tbl.Columns.Append "Column3", adVarWChar, 50
> >> | > |    cat.Tables.Append tbl
> >> | > |
> >> | > | End Sub
> >> | > | ----
> >> | > |
> >> | > | -- Gareth JenkinsJack Jack Two LTD
> >> | > |
> >> | > | www.jackjack2.co.uk


> >> | > | |

Newsbeitrag

> >> | > | | >
> >> | > | | > Have you tried ADOX ?
> >> | > | | >
> >> | > | | >
> >> | > | | >
> >> | > | | > --
> >> | > | | > Gareth Jenkins
> >> | > | | > Jack Jack Two LTD
> >> | > | | >
> >> | > | | > www.jackjack2.co.uk
> >> | > | | >
> >> | > | |
> >> | > | | Is the name property of a table writeable?
> >> | > | | Is there anywhere an example for rename a table with ADOX?
> >> | > | |
> >> | > | |
> >> | > |
> >> | > |
> >> | >
> >> | >
> >> |
> >> |



Sat, 17 Apr 2004 15:55:14 GMT  
 
 [ 12 post ] 

 Relevant Pages 

1. Renaming tables in the backend through vba

2. Rename existing table fields

3. Need Help Renaming Tables and Fields

4. Rename a table

5. Rename Table with Code?

6. Global renaming of table

7. Renaming FIelds in a Table

8. Renaming table fields bug

9. rename tables

10. Renaming a field in a table

11. HOWTO: rename a table's field from Access Basic

12. Renaming Tables

 

 
Powered by phpBB® Forum Software