473,756 Members | 1,676 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Best way to store dataset to disk???

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(str Folder & "app_data.x ml", XmlWriteMode.Wr iteSchema)
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(strF older & "app_data.xml", XmlReadMode.Rea dSchema)
'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 btnSubmitChange s Click event
Dim tblToModify as DataTable = ds.tables("Work Orders")
Dim rowToModify as DataRow = tblToModify.Row s.Find(strRowKe y)
rowToModify.Ite ms("Phone") = strNewPhoneNumb er
'....
ds.writexml(str Folder & "modified_data. xml", XmlWriteMode.Di ffGram)

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
13 2511
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(str Folder & "app_data.x ml", XmlWriteMode.Wr iteSchema)
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(strF older & "app_data.xml", XmlReadMode.Rea dSchema)
'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 btnSubmitChange s Click event
Dim tblToModify as DataTable = ds.tables("Work Orders")
Dim rowToModify as DataRow = tblToModify.Row s.Find(strRowKe y)
rowToModify.Ite ms("Phone") = strNewPhoneNumb er
'....
ds.writexml(str Folder & "modified_data. xml", XmlWriteMode.Di ffGram)

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
not very helpful advice, but at least it was rude.

su******@hotmai l.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(str Folder & "app_data.x ml", XmlWriteMode.Wr iteSchema)
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(strF older & "app_data.xml", XmlReadMode.Rea dSchema)
'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 btnSubmitChange s Click event
Dim tblToModify as DataTable = ds.tables("Work Orders")
Dim rowToModify as DataRow = tblToModify.Row s.Find(strRowKe y)
rowToModify.Ite ms("Phone") = strNewPhoneNumb er
'....
ds.writexml(str Folder & "modified_data. xml", XmlWriteMode.Di ffGram)

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
Create 2 datasets then merge them

Dataset1.Merge( Dataset2)

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

--
"processoriente d" <pr************ *@gmail.comwrot e in message
news:11******** *************@e 3g2000cwe.googl egroups.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(str Folder & "app_data.x ml", XmlWriteMode.Wr iteSchema)
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(strF older & "app_data.xml", XmlReadMode.Rea dSchema)
'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 btnSubmitChange s Click event
Dim tblToModify as DataTable = ds.tables("Work Orders")
Dim rowToModify as DataRow = tblToModify.Row s.Find(strRowKe y)
rowToModify.Ite ms("Phone") = strNewPhoneNumb er
'....
ds.writexml(str Folder & "modified_data. xml", XmlWriteMode.Di ffGram)

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
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
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=Northwi nd;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.Wr iteSchema)
Console.WriteLi ne("Loaded")
Case "Modify"
ds.ReadXml("C:\ MyData.xml", XmlReadMode.Rea dSchema)
ds.AcceptChange s()
Dim tbl As DataTable = ds.Tables("Cust omers")
tbl.Rows(1)("Co mpanyName") = "Modified Company Name"
tbl.Rows(2).Del ete()
tbl.Rows.Add("N EWCO", "New Company Name")
Dim intIndex As Integer = 0
For Each row As DataRow In tbl.Rows
Console.WriteLi ne("Row {0} - {1}", intIndex,
row.RowState)
intIndex = intIndex + 1
Next
ds.WriteXml("C: \MyData_dg.xml" , XmlWriteMode.Di ffGram)
Case "Review"
ds.ReadXml("C:\ MyData.xml", XmlReadMode.Rea dSchema)
ds.AcceptChange s()
If
My.Computer.Fil eSystem.FileExi sts("C:\MyData_ dg.xml") Then
Dim dsdg As New DataSet
dsdg.ReadXml("C :\MyData_dg.xml ",
XmlReadMode.Dif fGram)
ds.Merge(dsdg)
End If
Dim tbl As DataTable = ds.Tables("Cust omers")
Dim intIndex As Integer = 0
For Each row As DataRow In tbl.Rows
Console.WriteLi ne("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
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.ReadXmlSchem a("C:\MyData.xm l")
ds.AcceptChange s()
If
My.Computer.Fil eSystem.FileExi sts("C:\MyData_ dg.xml") Then
ds.ReadXml("C:\ MyData_dg.xml",
XmlReadMode.Dif fGram)
Else
ds.ReadXml("C:\ MyData.xml"XmlR eadMode.ReadSch ema)
ds.AcceptChange s()
End If
Dim tbl As DataTable = ds.Tables("Cust omers")
Dim intIndex As Integer = 0
For Each row As DataRow In tbl.Rows
Console.WriteLi ne("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
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.ReadXmlSchem a("C:\MyData.xm l")
ds.AcceptChange s()
If
My.Computer.Fil eSystem.FileExi sts("C:\MyData_ dg.xml") Then
ds.ReadXml("C:\ MyData_dg.xml",
XmlReadMode.Dif fGram)
Else
ds.ReadXml("C:\ MyData.xml"XmlR eadMode.ReadSch ema)
ds.AcceptChange s()
End If
Dim tbl As DataTable = ds.Tables("Cust omers")
Dim intIndex As Integer = 0
For Each row As DataRow In tbl.Rows
Console.WriteLi ne("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
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******@hotmai l.com wrote:
what.. these people don't support JET on the desktops?

Oct 21 '06 #9
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******@hotmai l.com wrote:
what.. these people don't support JET on the desktops?
Oct 23 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
6496
by: Dirk Reske | last post by:
Hello, i'm coding a newsreader like outlook. My question is, how to store the news. because one entry depends on another... when I want to display it in a treeview, I have to get all answers to an entry in a short time,while building the tree. a sql database where I good way in my eyes, but I can't say that the user have to install a sql server for a little app, like a newsreader! I hope, you've understood my english...i'm german :)
1
1064
by: Prince | last post by:
I'm doing the following but I'm not sure if there is a more efficient way to accomplish the same thing. In my Page_Load() method, I accessed a database and stored the information inside a DataSet. On my webpage, I have a DataList server control that binds to the DataSet. The method looks something like the following: Page_Load(){ //do the database connection plus binding
0
4247
by: Anonieko Ramos | last post by:
ASP.NET Forms Authentication Best Practices Dr. Dobb's Journal February 2004 Protecting user information is critical By Douglas Reilly Douglas is the author of Designing Microsoft ASP.NET Applications and owner of Access Microsystems. Doug can be reached at doug@accessmicrosystems.com. --------------------------------------------------------------------------------
3
1039
by: EMW | last post by:
My ASPX file is opened with two arguments, namely the Width and Height of the browser window. Since I've got more ASPX files, I need to keep these values. I was thinking of writing them in an XML file, but when I do this I get an error telling me my application does not have the right to write to disk. Suppose I place a new dataset file in the solution explorer, by adding it to my project, do I then always have access to this file from...
4
2190
by: bep | last post by:
Hello What is the best way to sort an XmlDocument for display in a DataGrig? I can use Xpath with an XpathExpression, and a XpathNavigator. But this XpathNavigator object is of no use to me, I need a XmlDocument. So is there an easy way to convert an XPathNavigator object to an XmlDocument? And I could use a piece of Xstl to transform the doc. But this seems like a lot of work. I would have to load the Xslt from file, cache it, and...
3
2700
by: Yul | last post by:
Hi, We are in the process of designing an ASP.NET app, where a user will enter some 'Customer ID' to be queried in the database. If the ID is valid, several stored procedures will be called to populate multiple webpages containing customer information. There isn't a one-to-one correlation between the stored procedure and a webpage. In other words, a webpage may have to refer to 1 or more DataTables to populate itself. Therefore, a...
4
1639
by: Dave | last post by:
(My apologies for posting this on two forums. I have just found out the other one was the incorrect location) I am writing a VB.NET 2003 web application to operate on my company's intranet. It accesses data in an SQL Server database. I have developed a couple of pages that display data successfully. However, there is one area that I am having trouble getting a handle on, despite purchasing a couple of Wrox books. Up until now, I have...
5
1987
by: Sukh | last post by:
I have to design a "Online Test Application" and application is going to display question and answers.All the questons are objective type so there is four answer for each question. My Question is where I shuld store the questions and answers. and how application can pick randomly question. right now I have all question in a text file. Please give me suggestion. I am using C# and asp.net for this. Regards, Sukh.
2
7651
by: hotflash | last post by:
Hi All, I found the best pure ASP code to upload a file to either server and/or MS Access Database. It works fine for me however, there is one thing that I don't like and have tried to fix but don't have any luck is to do a form validation. This script requires the files: db-file-to-disk.asp and _upload.asp. There is a DESCRIPTION field in the db-file-to-disk.asp file, what I want to do is the user has to field out this fied before...
0
9455
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
9838
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8709
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7242
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6534
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5302
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3805
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3354
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2665
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.