techmanbd Posted May 3, 2005 Posted May 3, 2005 OK, I have the following code below. I have been working on this for a week, and I think I need some professional help, before I need some psychotic professional help :D. I use an xml form to store data because it is local, and I won't have alot of data. I am able to get the data and save it. What I want to do is in the grid not show any data, just the scheme so I can add data without seeing the existing data. I have tried just using the scheme and saving the data, but that always wipes out the existing data so I read the data and get accept changes and then save and that works as far as saving and not deleting the existing data. So how would I go about having the datagrid show a blank rows of the scheme but will save without killing my existing data? Sub setup() dsComp = New DataSet dsComp.ReadXmlSchema(strPathSchema) dsComp.ReadXml(strPath, XmlReadMode.DiffGram) Me.DataGrid2.DataSource = dsComp.Tables("model") Me.DataGrid1.DataSource = dsComp.Tables("customer") Me.DataGrid3.DataSource = dsComp.Tables("part") End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click dsPart.AcceptChanges() dsPart.WriteXml(strPath, XmlWriteMode.DiffGram) End Sub Quote Live as if you were to die tomorrow. Learn as if you were to live forever. Gandhi
techmanbd Posted May 3, 2005 Author Posted May 3, 2005 Ok, I think I figured it out and will put my findings here for either critism or help for others I make 2 datasets, 1 with just the schema and 1 with the shema and data from the xml file. Then I enter my info into the datagrids. One datagrid thougj I do fill with data from the data filled dataset so I can see the customerID. Caused a problem when trying to fill the model datagrid because of key contraints, so I made enforcecontraints as false to add the number. Then I merged the 2 datasets, accepted the changes and saved the xmlfile. It worked. But if there is a better way, please critizise my code so I can learn something better. Sub setup() dsPart = New DataSet dsPart.ReadXmlSchema(strPathSchema) dsPart.ReadXml(strPath, XmlReadMode.DiffGram) dsComp = New DataSet dsComp.ReadXmlSchema(strPathSchema) Me.DataGrid2.DataSource = dsComp.Tables("model") Me.DataGrid1.DataSource = dsPart.Tables("customer") Me.DataGrid3.DataSource = dsComp.Tables("part") dsComp.EnforceConstraints = False End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click dsPart.Merge(dsComp, True) dsPart.AcceptChanges() dsPart.WriteXml(strPath, XmlWriteMode.DiffGram) dsComp.Dispose() dsPart.Dispose() Me.DataGrid2.DataSource = Nothing Me.DataGrid1.DataSource = Nothing Me.DataGrid3.DataSource = Nothing setup() End Sub Quote Live as if you were to die tomorrow. Learn as if you were to live forever. Gandhi
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.