Hi Vaish,
what I recomend is to create a new DataSet in the designer and drop a DataTable on it, and start to work from it. For example, I created I simple table with the following schema - I did it visually -
< xs:element name="Tests" msdata:IsDataSet="true" msdata:UseCurrentLocale="true" msprop:Generator_UserDSName="Tests" msprop:Generator_DataSetName="Tests">
< xs:complexType>
< xs:choice minOccurs="0" maxOccurs="unbounded">
< xs:element name="Test" msprop:Generator_UserTableName="Test" msprop:Generator_RowDeletedName="TestRowDeleted" msprop:Generator_TableClassName="TestDataTable" msprop:Generator_RowChangedName="TestRowChanged" msprop:Generator_RowClassName="TestRow" msprop:Generator_RowChangingName="TestRowChanging" msprop:Generator_RowEvArgName="TestRowChangeEvent" msprop:Generator_RowEvHandlerName="TestRowChangeEventHandler" msprop:Generator_TablePropName="Test" msprop:Generator_TableVarName="tableTest" msprop:Generator_RowDeletingName="TestRowDeleting">
< xs:complexType>
< xs:sequence>
< xs:element name="TestField1" msprop:Generator_UserColumnName="TestField1" msprop:Generator_ColumnPropNameInRow="TestField1" msprop:Generator_ColumnVarNameInTable="columnTestField1" msprop:Generator_ColumnPropNameInTable="TestField1Column" type="xs:string" minOccurs="0" />
< xs:element name="TestField2" msprop:Generator_UserColumnName="TestField2" msprop:Generator_ColumnPropNameInRow="TestField2" msprop:Generator_ColumnVarNameInTable="columnTestField2" msprop:Generator_ColumnPropNameInTable="TestField2Column" type="xs:string" minOccurs="0" />
</ xs:sequence>
</ xs:complexType>
</ xs:element>
</ xs:choice>
</ xs:complexType>
</ xs:element>
After that, I just linked my DataSet to a DataGrid and then I started to add items directly from my datagrid and this is the result of that operation. As you can see because of the schema, my Dataset's name is Tests and my table name is Test. Following the xml results is the code for doing that. Remember, I'm using a DataSet created visually in the designer according from what I need
< xml version="1.0" standalone="yes" > <Tests xmlns="http://tempuri.org/Tests.xsd"> <Test> <TestField1>2</TestField1> <TestField2>3</TestField2> </Test> <Test> <TestField1>4</TestField1> <TestField2>5</TestField2> </Test> <Test> <TestField1>67</TestField1> <TestField2>7</TestField2> </Test> </Tests>
Dim ds As New Tests
m_dgvClientes.DataSource = ds.Test
Dim dlg As SaveFileDialog = New SaveFileDialog
dlg.Filter = "Xml Files (*.xml)|*.xml"
dlg.ShowDialog()
If dlg.FileName.Length > 0 Then
ds.WriteXml(dlg.FileName)
End If
Best Regards
|