By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,505 Members | 1,200 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,505 IT Pros & Developers. It's quick & easy.

Best way to store dataset to disk???

P: n/a
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?

Oct 20 '06 #1
Share this Question
Share on Google+
13 Replies


P: n/a
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?
Oct 20 '06 #2

P: n/a
not very helpful advice, but at least it was rude.

su******@hotmail.com wrote:
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?
Oct 20 '06 #3

P: n/a
Create 2 datasets then merge them

Dataset1.Merge(Dataset2)

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

--
"processoriented" <pr*************@gmail.comwrote in message
news:11*********************@e3g2000cwe.googlegrou ps.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?
Oct 20 '06 #4

P: n/a
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
--
Oct 20 '06 #5

P: n/a
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.xm l") 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:
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
--
Oct 20 '06 #6

P: n/a
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.xm l") 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...

Oct 20 '06 #7

P: n/a
what.. these people don't support JET on the desktops?
processoriented wrote:
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.xm l") 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...
Oct 20 '06 #8

P: n/a
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.
su******@hotmail.com wrote:
what.. these people don't support JET on the desktops?

Oct 21 '06 #9

P: n/a
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:
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.
su******@hotmail.com wrote:
what.. these people don't support JET on the desktops?
Oct 23 '06 #10

P: n/a
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" <pr*************@gmail.comwrote in message
news:11**********************@i3g2000cwc.googlegro ups.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.xm l") 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...
Nov 27 '06 #11

P: n/a
a) a database on each users' machine isn't that bad of a deal
- simplifies code
- simplifies sorting

b) VB 2005 supports 'user instances' of SQL Server 2005 databases..
this makes #a plug and play

c) if that's too complex for you then put a database on a SERVER like
where it should be

d) stop bitching about 'overhead'; you're the dipshit that's using XML

-Susie, DBA


Ryan S. Thiele wrote:
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" <pr*************@gmail.comwrote in message
news:11**********************@i3g2000cwc.googlegro ups.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.xm l") 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...
Nov 27 '06 #12

P: n/a
BK
Don't worry about SusieDBA he/she has many aliases (Larry Linson,
Master Programmer, and Aaron.Kempf to name a few) to disguise his/her
frustration. Know that you can get a lot of useful information from
this forum and that you will need to weed through the occasional
childish rant.

Nov 27 '06 #13

P: n/a
it's not a childish RANT

keep your data in a DATABASE and spit on anyone that tells you
otherwise

-Susie

BK wrote:
Don't worry about SusieDBA he/she has many aliases (Larry Linson,
Master Programmer, and Aaron.Kempf to name a few) to disguise his/her
frustration. Know that you can get a lot of useful information from
this forum and that you will need to weed through the occasional
childish rant.
Nov 27 '06 #14

This discussion thread is closed

Replies have been disabled for this discussion.