Im writing an app where I want to store a local dataset temporarily before inserting into a database. The scenario is a sales environment where until the sale is confirmed I dont want the records inserted into the db.
My way of thinking was to create a predefined XSD within the project, and then map this to a dataset variable in my class until I eventually need to insert the data into the DB.
I have done this before on an ASP.net application and so I thought I would use the same method. In the ASP.net application (and in the app's case when the class is initialised) I map an XSD to a Dataset variable like so:
Public Sub LoadDataFromXSD(ByVal xsdName As String, ByVal txtDatasetName As String, ByVal txtTableName As String, ByRef TargetDataset As DataSet, ByRef targetDataTable As DataTable)
Dim dsTemplate As Data.DataSet = New Data.DataSet(txtDatasetName)
Dim xrdr As New System.Xml.XmlTextReader(xsdName)
dsTemplate.ReadXmlSchema(xrdr)
xrdr.Close()
TargetDataset = dsTemplate
targetDataTable = dsTemplate.Tables(txtTableName)
End Sub
The problem here is that when building or publishing the application, the XSD file is not included in the build and so the app falls over as in cannot find the xsd file.
I have tried changing the properties of the XSD file ("Build Action" and "Copy to Output Directory") but this isnt working.
Can anyone suggest anything here - either a resolution to this or a better way of handling the temporay records.
Or do you think inserting straight into the DB would be ok (and then deleting if the sale does not proceed?).
Note this is using .net framework 2.0
Thanks
Simon
My way of thinking was to create a predefined XSD within the project, and then map this to a dataset variable in my class until I eventually need to insert the data into the DB.
I have done this before on an ASP.net application and so I thought I would use the same method. In the ASP.net application (and in the app's case when the class is initialised) I map an XSD to a Dataset variable like so:
Public Sub LoadDataFromXSD(ByVal xsdName As String, ByVal txtDatasetName As String, ByVal txtTableName As String, ByRef TargetDataset As DataSet, ByRef targetDataTable As DataTable)
Dim dsTemplate As Data.DataSet = New Data.DataSet(txtDatasetName)
Dim xrdr As New System.Xml.XmlTextReader(xsdName)
dsTemplate.ReadXmlSchema(xrdr)
xrdr.Close()
TargetDataset = dsTemplate
targetDataTable = dsTemplate.Tables(txtTableName)
End Sub
The problem here is that when building or publishing the application, the XSD file is not included in the build and so the app falls over as in cannot find the xsd file.
I have tried changing the properties of the XSD file ("Build Action" and "Copy to Output Directory") but this isnt working.
Can anyone suggest anything here - either a resolution to this or a better way of handling the temporay records.
Or do you think inserting straight into the DB would be ok (and then deleting if the sale does not proceed?).
Note this is using .net framework 2.0
Thanks
Simon