Goksly Posted November 2, 2005 Posted November 2, 2005 Hello there :) I'm 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? :) Quote
bri189a Posted November 3, 2005 Posted November 3, 2005 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) Quote
Goksly Posted November 3, 2005 Author Posted November 3, 2005 Sorry I was most unclear in my first post. I'm 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? Quote
bri189a Posted November 4, 2005 Posted November 4, 2005 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 you'll get plenty of hits on the SQL syntax - I never do it, so I don't know off the top of my head. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.