SQL Queries to create,delete,rename a column column

sir,
  how to create,delete,rename a filed in MS-ACCESS database by using SQL Queries. i am using visual basic 6.0 as a front end. The database is in Access 97 format created by using Visual dataManager in Visual basic 6.0. i feel great if the Queries are in VB example.
sivasubramaniam_itAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

dmitryz6Commented:
You can use ADOX or DAO to do it


1.Using ADOX to create fileds

http://www.freevbcode.com/ShowCode.Asp?ID=3315

same way delete

ADOXtable.Columns.Delete "FieldName"

2.USing DAO

Dim db as DAO.database
dim td as DAO.tabledef
dim f as Dao.field

Set db = OpenDatabase("c:\Test.mdb")

Set td = db.CreateTableDef(InitialTable)

Set f = td.CreateField("ID", dbLong)
td.Fields.Append f
Set f = td.CreateField("dtmDate", dbDate)
f.Required = True
td.Fields.Append f
Set f = td.CreateField("sDesc", dbText)
f.AllowZeroLength = True
f.SIZE = 50
td.Fields.Append f
Set f = td.CreateField("cMemo", dbMemo)
td.Fields.Append f
.......

db.TableDefs.Append td
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

dmitryz6Commented:
You can try to use alter statement as well,not sure it will work from VB

.Execute "ALTER TABLE TableName ADD COLUMN ColumnName YesNo"

YesNo - datatype
0
leonstrykerCommented:
Go with dmitryz6's suggestion and use ADOX.

Leon
0
sivasubramaniam_itAuthor Commented:
i have get the solution for add and delete but i need how to rename.

for add
alter table table_name add field_name type
for delete
alter table table_name drop [column] field_name
0
dmitryz6Commented:
Try this, not sure It supported,if not use adox or DAO

ALTER TABLE table_name
   RENAME COLUMN field_name to field_name1
0
sivasubramaniam_itAuthor Commented:
sir,
                  it is not woking(rename) visual datamanager.
0
dmitryz6Commented:
Yes, what way sugested to use ADOX or ADO.

if you don't like to do it.Youcan Put data in temprory table.
Use Alter drop statement to delete dat
Use Alter Add statment to add column
And return dat back.

But better use Adox or DAO
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.