Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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? :)

Posted

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)

Posted

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?

Posted
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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...