draget Posted November 9, 2006 Posted November 9, 2006 Hi, I have a script which executes perfectly with not errors, however it simply does not work! Dim cb As New OleDb.OleDbCommandBuilder(TableForm.da) Dim thenewcol As New System.Data.DataColumn thenewcol.ColumnName = nameofcol.Text TableForm.ds.Tables("PeriodicDB").Columns.Add(thenewcol) TableForm.da.Update(TableForm.ds, "PeriodicDB") TableForm.setup() Public Sub setup() ds.Clear() con.ConnectionString = "PROVIDER = Microsoft.Jet.OLEDB.4.0; DATA Source = " + path Try con.Open() Catch ex As Exception lblStatus.Text = "Error!" lblLink.Text = "Details..." exceptionText = ex.ToString() Return End Try sql = "SELECT * FROM PeriodicElements" da = New OleDb.OleDbDataAdapter(sql, con) da.Fill(ds, "PeriodicDB") sql = "SELECT * FROM data_inc" da2 = New OleDb.OleDbDataAdapter(sql, con) da2.Fill(ds, "ColNames") tot_columns = ds.Tables("PeriodicDB").Columns.Count lblStatus.Text = ("Connection to DB was successful.") lblLink.Text = "" con.Close() End Sub As I said before, there are no errors, it simply doesn't work, the database remains unchanged. One thing interesting to note, is that when setup recounts the columns, it includes the new column in its count, yet for all I can see it isn't in the database, and then my program crashes trying to access the item at the last count. Any ideas? Thanks, Tom Quote
FZelle Posted November 9, 2006 Posted November 9, 2006 To create a new column in the DataBase you can't use this way. You have to use a normal SQL-Command like "ALTER TABLE ADD COLUMNNAME COLTYPE". 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.