Friday, December 14, 2007

How to add a new column into a table?

How to add a new column into a table?

We can use the "Execute" method in the ADO connection to add a column into the table:

<%

Set conn = Server.CreateObject("Adodb.Connection")

conn.Open "Driver={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("db1.mdb")

conn.execute "ALTER TABLE master ADD COLUMN name Text(50)"

'ALTER TABLE master - Select the table

'ADD COLUMN name Text(50) - set the information about the new column.

%>

No comments: