Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi Guys!

 

just a quick question, i cannot find anywhere how to add a database column through code.

 

I am comparing two access database one which is a new one i have created manually with all the correct columns and another which is older with none of the new columns included.

 

i know how to find whether the columns exist in the old table but do not know how to add new one if i need to.

 

i tried the following but the database remains unchanged.

 

 
               ds2.Tables(TextBox9.Text).Columns.Add("ABC123, ds.Tables(TextBox8.Text).Columns(d).DataType)
               Dim cb As New OleDb.OleDbCommandBuilder(da2)
               da2.Update(ds2, TextBox9.Text)

 

Thanks in advance for any help

 

Regards

Bluejag.:D

  • Administrators
Posted

I am assuming ds2 is a DataSet, in which case the .Columns.Add bit is adding a column to the in memory DataSet and not the underlying database, the call to da2.Update will only send back changes to the data, not to the underlying schema.

 

Your best bet is probably to use the Alter Table command

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

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