bluejaguar456 Posted October 15, 2009 Posted October 15, 2009 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 Quote
Administrators PlausiblyDamp Posted October 16, 2009 Administrators Posted October 16, 2009 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 Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
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.