Renaming Columns....

Goksly

Active member
Joined
Aug 8, 2005
Messages
26
Hello there :)
Im creating a multi database interface and one of the things I want to do is let the user change the column name. I am finding huge difficulty in finding the code to alter a columns name. Adding or deleting a column seems a piece of ....

So er yeah... can anyone point me in the right direction please? :)
 
Dim ds as MyDataSet

If MyDataSet.Tables(0).Columns(0).ColumnName = "QWERTY" Then
MyDataSet.Tables(0).Columns(0).ColumnName = "ASDF"
End If

Add a column that holds string values
MyDataSet.Tables(0).Columns.Add("ColumnName", GetType(String))

Remove a column
MyDataSet.Tables(0).Columns.Remove("ColumnName")
Remove a column by column Index
MyDataSet.Tables(0).Columns.Remove(4)
 
Sorry I was most unclear in my first post.
Im actually trying to change the name of a column on an ACCESS database... So I really need the SQL to change it, or if there is another round - about method... i.e. can you extract the schema to a dataset, change the column name and update the database that way?
 
Yes, the same SQL statement you use to ALTER TABLE normally can be called from within .NET. Do a search for ALTER TABLE on Google and youll get plenty of hits on the SQL syntax - I never do it, so I dont know off the top of my head.
 
Back
Top