Re: rename a column i Access
From: TroelsM (TroelsM_at_discussions.microsoft.com)
Date: 11/07/04
- Next message: Mich: "Re: how to use a variable into a select?"
- Previous message: Bob Barrows [MVP]: "Re: how to use a variable into a select?"
- In reply to: Bob Barrows [MVP]: "Re: rename a column i Access"
- Messages sorted by: [ date ] [ thread ]
Date: Sun, 7 Nov 2004 07:30:02 -0800
Hi Bob,
thanks for You answer - I can´t remember where I found the rename.
So I made it with ADD new , and DELETE old and used a loop to transfer
values, because I could not get UPDATE to work.
But I followed Your example with changing the driver to JET and now my
Update command works - so I don't have to loop to all records to transfer the
values.
Tx
"Bob Barrows [MVP]" wrote:
> TroelsM wrote:
> > Hi there !
> > I am trying to rename a column i Access
> > Set Conn1 = Server.CreateObject("ADODB.Connection")
> > Conn1.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" &
> > Server.MapPath("\fpdb\currency.mdb")
> > sSQL = "ALTER TABLE DatoCurrency "
> > sSQL = sSQL & " COLUMN " & ucase(retcur) & " RENAME TO " &
> > UCASE(chkstring(request.form("cur"),"SQLString"))
> > conn1.execute sSQL
> > conn1.close
> >
> > but I keep getting this error.
> > »»Microsoft][ODBC Microsoft Access Driver] Syntax error in ALTER TABLE
> > statement.««
>
> Nothing to do with your problem, but you should stop using the obsolete ODBC
> driver. The native Jet OLEDB provider offers more functionality and is more
> robust. See www.able-consulting.com/ado_conn.htm for an example.
>
> >
> > AnyOne know what I am doing wrong or have any idea on how to do this
>
> Ray's already taken care of the multiposting problem, so I will concentrate
> on the actual problem, doing it here in this group since it is a
> database-related question (hence the "db" in the newsgroup name).
>
> Where did you find the RENAME keyword? It certainly is not mentioned in
> Access online help (see the Microsoft Jet SQL Reference section in the table
> of contents).
>
> The only way to rename a column using DDL SQL (Data Definition Language) is
> to add a column:
>
> ALTER TABLE DatoCurrency ADD COLUMN NewName datatype(size)
>
> Run an update statement to copy the data from the old column to the new one:
> UPDATE DatoCurrency SET NewName = OldName
>
> Then drop the old column:
> ALTER TABLE DatoCurrency DROP COLUMN OldName
>
> You can use ADOX to rename a column. Search www.aspfaq.com for an example
> (use the keywords column and ADOX).
>
> Bob Barrows
>
> --
> Microsoft MVP - ASP/ASP.NET
> Please reply to the newsgroup. This email account is my spam trap so I
> don't check it very often. If you must reply off-line, then remove the
> "NO SPAM"
>
>
>
- Next message: Mich: "Re: how to use a variable into a select?"
- Previous message: Bob Barrows [MVP]: "Re: how to use a variable into a select?"
- In reply to: Bob Barrows [MVP]: "Re: rename a column i Access"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|