(Domestic version)
After several days of continuous research on ADO. net, and found another good function... That is, how to use it (if there is no error, related functions are also available in ado !)Writwxml,WritexmlschemaExport the data and schema structure in the datatable to the XML file on the hard disk, or useReadxml,ReadxmlschemaLoad the data and schema structure in the XML file into the able object in the dataset.
In some cases, data may need to be stored on the hard disk... To prevent unexpected demands...
' Declare Variables
Dim CN As Sqlconnection
Dim Da As Sqldataadapter
Dim DS As Dataset
Try
' Columnized sqlconnection object and connection string
CN = New Sqlconnection ( " Data Source = localhost; initial catalog = northwind; Integrated Security = true " )
CN. open ()
' Real-column DataSet object
DS = New Dataset
' Materialized sqldataadapter
Da = New Sqldataadapter ( " Select * from MERs " , CN)
' Load the data returned by SQL Server to the datatable
Da. Fill (DS)
' Bind dataset to the DataGrid Control
Datagrid1.datasource = DS
Catch Ex As Sqlexception
' Error message displayed here
Finally
CN. Close ()
End Try
Try
' Export table structure to the XSD File
DS. writexmlschema ( " C: \ table-def.xsd " )
' Export the data in the datatable to an XML file
DS. writexml ( " C: \ table-data.xml " )
Catch Ex As Exception
' Error message displayed here
End Try
Try
' Create a new DataSet object
DS = New Dataset
' Load table structure into Dataset
DS. readxmlschema ( " C: \ table-def.xsd " )
' Load XML data into datatable
DS. readxml ( " C: \ table-data.xml " )
' Bind dataset to the DataGrid Control
Datagrid1.datasource = DS
Catch Ex As Exception
' Error message displayed here
End Try