I have to dynamically add new columns to a table in a database and also save it for persistence. I am unable to do that. I am submitting the code sample I used to do the task.
Dim newcol = NewDataColumn("AccountNumber", GetType(Integer))
newcol.AllowDBNull = true
TestaddcolsDataSet.bank.Columns.Add(newcol)
str = TestaddcolsDataSet.bank.Columns.Count
TestaddcolsDataSet.bank.Rows.Add(7, "Stephen","HSBC bank","52368965212")
Try
Me.BankTableAdapter.Update(TestaddcolsDataSet.bank)
Catch ex AsException
MsgBox("unable to update")
EndTry
I have 3 exiting columns in the table and want to add a fourth column with the above code. With the MsgBox code, I could find that the new column is created but after closing the application, it is not saved in the database.Can somebody help me to correctly code this problem?
Thanks in advancr to all the contributors
Dim newcol = NewDataColumn("AccountNumber", GetType(Integer))
newcol.AllowDBNull = true
TestaddcolsDataSet.bank.Columns.Add(newcol)
str = TestaddcolsDataSet.bank.Columns.Count
TestaddcolsDataSet.bank.Rows.Add(7, "Stephen","HSBC bank","52368965212")
Try
Me.BankTableAdapter.Update(TestaddcolsDataSet.bank)
Catch ex AsException
MsgBox("unable to update")
EndTry
I have 3 exiting columns in the table and want to add a fourth column with the above code. With the MsgBox code, I could find that the new column is created but after closing the application, it is not saved in the database.Can somebody help me to correctly code this problem?
Thanks in advancr to all the contributors
Last edited: