How2 save changes to dataSET made at runtime?

How2 save changes to dataSET made at runtime?

Postby robofx » Fri 28 Nov 2008 03:47

I have a database with no datatable. I add a datatable (temp1) and 3 columns (column1, column2 and column3) to that datatable (by setting the CommandText property of a Command object called m_cmd and then invoking the ExecuteNonQuery method.) (Also, m_conn is the connection that m_cmd uses to talk to the database.)

I then add the same datatable & columns to the corresponding typed dataset (m_ds) which I created at design time using the Devart Dataset Wizard. These are both done at runtime programatically by clicking the button called m_createTableButton.

I exit my application and re-start it. The database retains those changes (the new datatable & its new columns are still there), but the dataset does not. It's still in the original form, as if I'd never made those changes.

How do I save those dataset changes before exiting the app? Does it have something to do with the WriteXmlSchema method of the m_ds dataset?

Private Sub m_createTableButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles m_createTableButton.Click

'Create a new table & 3 columns in the dataBASE
m_cmd.CommandText = "CREATE TABLE temp1 (column1 character varying(10), column2 character varying(10), column3 character varying(10))"

'Now create the same table & 3 columns in the dataSET
Dim temp1 As DataTable = New DataTable("temp1")
temp1.Columns.Add("column1", GetType(System.Char))
temp1.Columns.Add("column2", GetType(System.Char))
temp1.Columns.Add("column3", GetType(System.Char))

m_ds.Tables.AddRange(New DataTable() {temp1})

End Sub
Posts: 8
Joined: Fri 14 Nov 2008 22:13
Location: East Coast, USA

Postby AndreyR » Fri 28 Nov 2008 10:29

The method WriteXmlSchema() writes untyped DataSet to a file.
If you want to save chages you made in runtime to the typed DataSet, you should act in the way similar to the one described in the post ,
but we cannot guarantee the workability of this solution, because we do not support it officially.
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Return to dotConnect for PostgreSQL