add column in database dynamically

tanmoy

New member
Joined
Mar 11, 2006
Messages
2
hello sir.i am beginner in vb.net.i have a problem.i have a table name "trans".i want to add column in this table dynamicaly and also remove column dynamically.the column name will be given by d user.and i also tell the column number.suppose in my "trans" table there are three columns.the column names are "cake","pastry","totalquan".now i want to add a column name biscuit after the pastry column.how can i do this? this is my problem.please help me.my programe is write in vb.net and my database is in ms.access.help me please.
 
The syntax for the query should be "Alter table trans add biscuit <type of value here>"
You shouldnt worry about the order of the columns because you can arrange them when you make the select clause: "Select cake, pastry, biscuit, totalquan from trans"

If you want to drop a column: "Alter table trans drop column biscuit"
That should do it
 
Just out of interest is there areason why you need to be able to add / remove columns dynamically?

Although technically possible (as Puiu explained above) it is most definately not a normal way for a database to be maintained. If you gave a bit more detail about what you are trying to achieve then there may be a better alternative.
 
Back
Top