Home All Groups Group Topic Archive Search About

Best way to store dataset to disk???

Author
20 Oct 2006 7:55 PM
processoriented
I am trying to find the best approach to do something here...
situation is this...  One of the tables in my dataset is a "Work Order"
table with information about what needs to be done and where.  Say my
user goes on site to do the work associated with the work order, and
while he is there, he discovers that the customer's phone number has
changed.  Should be no problem, he opens up the app, looks at his list
of open work orders, finds the work order in question, and changes the
phone number.  When he re-connects to the network and has access to the
database, the app just updates the work order table with the new phone
number.  This is pretty simple, on the initial download to the user's
machine, I just store the work order table (along with everything else
in the dataset) to an xml doc like this:

Dim ds as New DataSet
' code to connect to database and fill the dataset goes here
ds.writexml(strFolder & "app_data.xml", XmlWriteMode.WriteSchema)


Great... user then turns off his machine, goes out to the customer's
site and realizes that the phone number needs to be changed... now when
he turns on his computer and fires up the application, it needs to show
him a list of his open work orders... again, this is simple:

Dim ds as New DataSet
ds.readxml(strFolder & "app_data.xml",XmlReadMode.ReadSchema)
'Code to parse through the dataset and display the relavant information
goes here...

Now that my user can see and modify all his open work orders, my code
will let him make modifications like this...

'This code appears in the btnSubmitChanges Click event
Dim tblToModify as DataTable = ds.tables("WorkOrders")
Dim rowToModify as DataRow = tblToModify.Rows.Find(strRowKey)
rowToModify.Items("Phone") = strNewPhoneNumber
'....
ds.writexml(strFolder & "modified_data.xml", XmlWriteMode.DiffGram)

Fantastic! Now my dataset has a record, not only of what the new phone
number is, but what it used to be, and I can use the rowstate
properties to look at both sets of information... but here is where I
am confused:
I can save the changes with a DiffGram style XML doc, but then what do
I do with the original XML doc and the DiffGram when I get back
on-line?

Moreover, what happens if my user switches off the computer and
switches it back on?  Sure the computer has a record of the modified
data in the diffgram xml doc, but the code isn't looking there to show
him his list of open work-orders.

Basically what I am asking is this:  I have my base data and my
modifications stored in a couple of XML docs, but how do I take the
information in those two xml docs and turn them back into the same
dataset I had right after my user made his changes?  Or, should it
really be two different documents? Is there a way to do it in one
document?  What happens if the user makes multiple modifications to the
data, turning on and off the computer in between each modification
prior to sending those changes back to the database?

Author
20 Oct 2006 8:11 PM
susiedba@hotmail.com
store it in a database; jackass


processoriented wrote:
Show quoteHide quote
> I am trying to find the best approach to do something here...
> situation is this...  One of the tables in my dataset is a "Work Order"
> table with information about what needs to be done and where.  Say my
> user goes on site to do the work associated with the work order, and
> while he is there, he discovers that the customer's phone number has
> changed.  Should be no problem, he opens up the app, looks at his list
> of open work orders, finds the work order in question, and changes the
> phone number.  When he re-connects to the network and has access to the
> database, the app just updates the work order table with the new phone
> number.  This is pretty simple, on the initial download to the user's
> machine, I just store the work order table (along with everything else
> in the dataset) to an xml doc like this:
>
> Dim ds as New DataSet
> ' code to connect to database and fill the dataset goes here
> ds.writexml(strFolder & "app_data.xml", XmlWriteMode.WriteSchema)
>
>
> Great... user then turns off his machine, goes out to the customer's
> site and realizes that the phone number needs to be changed... now when
> he turns on his computer and fires up the application, it needs to show
> him a list of his open work orders... again, this is simple:
>
> Dim ds as New DataSet
> ds.readxml(strFolder & "app_data.xml",XmlReadMode.ReadSchema)
> 'Code to parse through the dataset and display the relavant information
> goes here...
>
> Now that my user can see and modify all his open work orders, my code
> will let him make modifications like this...
>
> 'This code appears in the btnSubmitChanges Click event
> Dim tblToModify as DataTable = ds.tables("WorkOrders")
> Dim rowToModify as DataRow = tblToModify.Rows.Find(strRowKey)
> rowToModify.Items("Phone") = strNewPhoneNumber
> '....
> ds.writexml(strFolder & "modified_data.xml", XmlWriteMode.DiffGram)
>
> Fantastic! Now my dataset has a record, not only of what the new phone
> number is, but what it used to be, and I can use the rowstate
> properties to look at both sets of information... but here is where I
> am confused:
> I can save the changes with a DiffGram style XML doc, but then what do
> I do with the original XML doc and the DiffGram when I get back
> on-line?
>
> Moreover, what happens if my user switches off the computer and
> switches it back on?  Sure the computer has a record of the modified
> data in the diffgram xml doc, but the code isn't looking there to show
> him his list of open work-orders.
>
> Basically what I am asking is this:  I have my base data and my
> modifications stored in a couple of XML docs, but how do I take the
> information in those two xml docs and turn them back into the same
> dataset I had right after my user made his changes?  Or, should it
> really be two different documents? Is there a way to do it in one
> document?  What happens if the user makes multiple modifications to the
> data, turning on and off the computer in between each modification
> prior to sending those changes back to the database?
Author
20 Oct 2006 8:23 PM
processoriented
not very helpful advice, but at least it was rude.

susie***@hotmail.com wrote:
Show quoteHide quote
> store it in a database; jackass
>
>
> processoriented wrote:
> > I am trying to find the best approach to do something here...
> > situation is this...  One of the tables in my dataset is a "Work Order"
> > table with information about what needs to be done and where.  Say my
> > user goes on site to do the work associated with the work order, and
> > while he is there, he discovers that the customer's phone number has
> > changed.  Should be no problem, he opens up the app, looks at his list
> > of open work orders, finds the work order in question, and changes the
> > phone number.  When he re-connects to the network and has access to the
> > database, the app just updates the work order table with the new phone
> > number.  This is pretty simple, on the initial download to the user's
> > machine, I just store the work order table (along with everything else
> > in the dataset) to an xml doc like this:
> >
> > Dim ds as New DataSet
> > ' code to connect to database and fill the dataset goes here
> > ds.writexml(strFolder & "app_data.xml", XmlWriteMode.WriteSchema)
> >
> >
> > Great... user then turns off his machine, goes out to the customer's
> > site and realizes that the phone number needs to be changed... now when
> > he turns on his computer and fires up the application, it needs to show
> > him a list of his open work orders... again, this is simple:
> >
> > Dim ds as New DataSet
> > ds.readxml(strFolder & "app_data.xml",XmlReadMode.ReadSchema)
> > 'Code to parse through the dataset and display the relavant information
> > goes here...
> >
> > Now that my user can see and modify all his open work orders, my code
> > will let him make modifications like this...
> >
> > 'This code appears in the btnSubmitChanges Click event
> > Dim tblToModify as DataTable = ds.tables("WorkOrders")
> > Dim rowToModify as DataRow = tblToModify.Rows.Find(strRowKey)
> > rowToModify.Items("Phone") = strNewPhoneNumber
> > '....
> > ds.writexml(strFolder & "modified_data.xml", XmlWriteMode.DiffGram)
> >
> > Fantastic! Now my dataset has a record, not only of what the new phone
> > number is, but what it used to be, and I can use the rowstate
> > properties to look at both sets of information... but here is where I
> > am confused:
> > I can save the changes with a DiffGram style XML doc, but then what do
> > I do with the original XML doc and the DiffGram when I get back
> > on-line?
> >
> > Moreover, what happens if my user switches off the computer and
> > switches it back on?  Sure the computer has a record of the modified
> > data in the diffgram xml doc, but the code isn't looking there to show
> > him his list of open work-orders.
> >
> > Basically what I am asking is this:  I have my base data and my
> > modifications stored in a couple of XML docs, but how do I take the
> > information in those two xml docs and turn them back into the same
> > dataset I had right after my user made his changes?  Or, should it
> > really be two different documents? Is there a way to do it in one
> > document?  What happens if the user makes multiple modifications to the
> > data, turning on and off the computer in between each modification
> > prior to sending those changes back to the database?
Author
20 Oct 2006 8:37 PM
Ryan S. Thiele
Create 2 datasets then merge them

Dataset1.Merge(Dataset2)

Try this


--
Thiele Enterprises - The Power Is In Your Hands Now!

--
"processoriented" <processorien***@gmail.com> wrote in message
news:1161374105.681467.93580@e3g2000cwe.googlegroups.com...
I am trying to find the best approach to do something here...
situation is this...  One of the tables in my dataset is a "Work Order"
table with information about what needs to be done and where.  Say my
user goes on site to do the work associated with the work order, and
while he is there, he discovers that the customer's phone number has
changed.  Should be no problem, he opens up the app, looks at his list
of open work orders, finds the work order in question, and changes the
phone number.  When he re-connects to the network and has access to the
database, the app just updates the work order table with the new phone
number.  This is pretty simple, on the initial download to the user's
machine, I just store the work order table (along with everything else
in the dataset) to an xml doc like this:

Dim ds as New DataSet
' code to connect to database and fill the dataset goes here
ds.writexml(strFolder & "app_data.xml", XmlWriteMode.WriteSchema)


Great... user then turns off his machine, goes out to the customer's
site and realizes that the phone number needs to be changed... now when
he turns on his computer and fires up the application, it needs to show
him a list of his open work orders... again, this is simple:

Dim ds as New DataSet
ds.readxml(strFolder & "app_data.xml",XmlReadMode.ReadSchema)
'Code to parse through the dataset and display the relavant information
goes here...

Now that my user can see and modify all his open work orders, my code
will let him make modifications like this...

'This code appears in the btnSubmitChanges Click event
Dim tblToModify as DataTable = ds.tables("WorkOrders")
Dim rowToModify as DataRow = tblToModify.Rows.Find(strRowKey)
rowToModify.Items("Phone") = strNewPhoneNumber
'....
ds.writexml(strFolder & "modified_data.xml", XmlWriteMode.DiffGram)

Fantastic! Now my dataset has a record, not only of what the new phone
number is, but what it used to be, and I can use the rowstate
properties to look at both sets of information... but here is where I
am confused:
I can save the changes with a DiffGram style XML doc, but then what do
I do with the original XML doc and the DiffGram when I get back
on-line?

Moreover, what happens if my user switches off the computer and
switches it back on?  Sure the computer has a record of the modified
data in the diffgram xml doc, but the code isn't looking there to show
him his list of open work-orders.

Basically what I am asking is this:  I have my base data and my
modifications stored in a couple of XML docs, but how do I take the
information in those two xml docs and turn them back into the same
dataset I had right after my user made his changes?  Or, should it
really be two different documents? Is there a way to do it in one
document?  What happens if the user makes multiple modifications to the
data, turning on and off the computer in between each modification
prior to sending those changes back to the database?
Author
20 Oct 2006 8:52 PM
processoriented
Hi Ryan,

Thanks... I was just thinking something along those lines... I will
experiment and let you know how it goes.

Ryan S. Thiele wrote:
Show quoteHide quote
> Create 2 datasets then merge them
>
> Dataset1.Merge(Dataset2)
>
> Try this
>
>
> --
Author
20 Oct 2006 9:45 PM
processoriented
Hi Again Ryan,

I tried to come up with a simple Console App that would test the merge
function... and got these results...

Dim strConn, strSQL As String
        Dim ds As New DataSet()
        Dim strMode As String
        strMode = "Load"
        strMode = "Modify"
        strMode = "Review"

        Select Case strMode
            Case "Load"
                strConn = "Data Source=(local);" & _
                          "Initial Catalog=Northwind;Integrated
Security=True;"
                strSQL = "SELECT TOP 3 CustomerID, CompanyName FROM
Customers"
                Dim da As New SqlDataAdapter(strSQL, strConn)
                da.Fill(ds, "Customers")

                ds.WriteXml("C:\MyData.xml", XmlWriteMode.WriteSchema)
                Console.WriteLine("Loaded")
            Case "Modify"
                ds.ReadXml("C:\MyData.xml", XmlReadMode.ReadSchema)
                ds.AcceptChanges()
                Dim tbl As DataTable = ds.Tables("Customers")
                tbl.Rows(1)("CompanyName") = "Modified Company Name"
                tbl.Rows(2).Delete()
                tbl.Rows.Add("NEWCO", "New Company Name")
                Dim intIndex As Integer = 0
                For Each row As DataRow In tbl.Rows
                    Console.WriteLine("Row {0} - {1}", intIndex,
row.RowState)
                    intIndex = intIndex + 1
                Next
                ds.WriteXml("C:\MyData_dg.xml", XmlWriteMode.DiffGram)
            Case "Review"
                ds.ReadXml("C:\MyData.xml", XmlReadMode.ReadSchema)
                ds.AcceptChanges()
                If
My.Computer.FileSystem.FileExists("C:\MyData_dg.xml") Then
                    Dim dsdg As New DataSet
                    dsdg.ReadXml("C:\MyData_dg.xml",
XmlReadMode.DiffGram)
                    ds.Merge(dsdg)
                End If
                Dim tbl As DataTable = ds.Tables("Customers")
                Dim intIndex As Integer = 0
                For Each row As DataRow In tbl.Rows
                    Console.WriteLine("Row {0} - {1}", intIndex,
row.RowState)
                    intIndex = intIndex + 1
                Next
        End Select

When I run the app in "Modify" mode, I see the following on my console:

Row 0 - Unchanged
Row 1 - Modified
Row 2 - Deleted
Row 3 - Added


If I can get the merge function to work the way I want it, then I
should see the same when I run the app in "Review" mode, but instead, I
am seeing this...

Row 0 - Unchanged
Row 1 - Unchanged
Row 2 - Unchanged

Any ideas?

Thanks again for the advice!


processoriented wrote:
Show quoteHide quote
> Hi Ryan,
>
> Thanks... I was just thinking something along those lines... I will
> experiment and let you know how it goes.
>
> Ryan S. Thiele wrote:
> > Create 2 datasets then merge them
> >
> > Dataset1.Merge(Dataset2)
> >
> > Try this
> >
> >
> > --
Author
20 Oct 2006 10:02 PM
processoriented
Hello Again,

I just got it!   Instead of merging the old data with the new, I just
grab the schema from the original and apply the diffgram for the
data...

The new code looks like this:

             Case "Review"
                 ds.ReadXmlSchema("C:\MyData.xml")
                 ds.AcceptChanges()
                 If
My.Computer.FileSystem.FileExists("C:\MyData_dg.xml") Then
                     ds.ReadXml("C:\MyData_dg.xml",
XmlReadMode.DiffGram)
                Else
                     ds.ReadXml("C:\MyData.xml"XmlReadMode.ReadSchema)
                     ds.AcceptChanges()
                End If
                 Dim tbl As DataTable = ds.Tables("Customers")
                 Dim intIndex As Integer = 0
                 For Each row As DataRow In tbl.Rows
                     Console.WriteLine("Row {0} - {1}", intIndex,
row.RowState)
                     intIndex = intIndex + 1
                 Next
         End Select

....Then again, I could have gone with SusieDBA's recommendation and
incurred the overhead of adding a database to every user's machine...
Author
20 Oct 2006 10:47 PM
susiedba@hotmail.com
what.. these people don't support JET on the desktops?


processoriented wrote:
Show quoteHide quote
> Hello Again,
>
> I just got it!   Instead of merging the old data with the new, I just
> grab the schema from the original and apply the diffgram for the
> data...
>
> The new code looks like this:
>
>              Case "Review"
>                  ds.ReadXmlSchema("C:\MyData.xml")
>                  ds.AcceptChanges()
>                  If
> My.Computer.FileSystem.FileExists("C:\MyData_dg.xml") Then
>                      ds.ReadXml("C:\MyData_dg.xml",
> XmlReadMode.DiffGram)
>                 Else
>                      ds.ReadXml("C:\MyData.xml"XmlReadMode.ReadSchema)
>                      ds.AcceptChanges()
>                 End If
>                  Dim tbl As DataTable = ds.Tables("Customers")
>                  Dim intIndex As Integer = 0
>                  For Each row As DataRow In tbl.Rows
>                      Console.WriteLine("Row {0} - {1}", intIndex,
> row.RowState)
>                      intIndex = intIndex + 1
>                  Next
>          End Select
>
> ...Then again, I could have gone with SusieDBA's recommendation and
> incurred the overhead of adding a database to every user's machine...
Author
21 Oct 2006 1:44 PM
processoriented
Well, sure they do... but my solution only requires ten lines of code.
creating and maintaining databases on every machine seems much more
complex.

look, I don't mean any offence, but I came to this forum with a
question on how to use a function that was clearly designed into
ADO.NET & vb; and your recommendation read like you were telling me
that I was a "jackass" for wanting to use this function, yet the
alternative you offered was more complicated.    Back in the ADODB days
I had tried a JET db for a similar function, and it took over a hundred
lines of code to create the database just like I wanted it... maybe
going from ADO.NET to Jet is easier than ADODB to Jet was, maybe its
not, but the experience from the old days made me think that finding a
completely .Net solution that didn't require any of the mucking about
with jet was preferable.  Now that I have the functionality that I
wanted, I feel vindicated.


susie***@hotmail.com wrote:
Show quoteHide quote
> what.. these people don't support JET on the desktops?
>
>
Author
23 Oct 2006 8:41 PM
susiedba@hotmail.com
100 lines of code?

I could build amazon.com in 100 lines of code.. ROFL

VB.net and your ADO.net and all that other crap is 100 times more
verbose..



processoriented wrote:
Show quoteHide quote
> Well, sure they do... but my solution only requires ten lines of code.
> creating and maintaining databases on every machine seems much more
> complex.
>
> look, I don't mean any offence, but I came to this forum with a
> question on how to use a function that was clearly designed into
> ADO.NET & vb; and your recommendation read like you were telling me
> that I was a "jackass" for wanting to use this function, yet the
> alternative you offered was more complicated.    Back in the ADODB days
> I had tried a JET db for a similar function, and it took over a hundred
> lines of code to create the database just like I wanted it... maybe
> going from ADO.NET to Jet is easier than ADODB to Jet was, maybe its
> not, but the experience from the old days made me think that finding a
> completely .Net solution that didn't require any of the mucking about
> with jet was preferable.  Now that I have the functionality that I
> wanted, I feel vindicated.
>
>
> susie***@hotmail.com wrote:
> > what.. these people don't support JET on the desktops?
> >
> >
Author
27 Nov 2006 1:59 PM
Ryan S. Thiele
I would use whichever way. Keep in mind the resources.
Remember, slow apps never get used :)

--
Thiele Enterprises - The Power Is In Your Hands Now!

--
"processoriented" <processorien***@gmail.com> wrote in message
news:1161381758.315092.210700@i3g2000cwc.googlegroups.com...
Hello Again,

I just got it!   Instead of merging the old data with the new, I just
grab the schema from the original and apply the diffgram for the
data...

The new code looks like this:

             Case "Review"
                 ds.ReadXmlSchema("C:\MyData.xml")
                 ds.AcceptChanges()
                 If
My.Computer.FileSystem.FileExists("C:\MyData_dg.xml") Then
                     ds.ReadXml("C:\MyData_dg.xml",
XmlReadMode.DiffGram)
                Else
                     ds.ReadXml("C:\MyData.xml"XmlReadMode.ReadSchema)
                     ds.AcceptChanges()
                End If
                 Dim tbl As DataTable = ds.Tables("Customers")
                 Dim intIndex As Integer = 0
                 For Each row As DataRow In tbl.Rows
                     Console.WriteLine("Row {0} - {1}", intIndex,
row.RowState)
                     intIndex = intIndex + 1
                 Next
         End Select

....Then again, I could have gone with SusieDBA's recommendation and
incurred the overhead of adding a database to every user's machine...