473,385 Members | 1,465 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Update DataSet

I have created a xml doc that stores dates. On the first of the year I
want to upload the xml doc into a dataset and then loop through it
adding one year to those dates.

This is what I have attempted.

myData.ReadXml("this.xml")
myTable = myData.Tables("myInformation")

myRow = myData.Tables("myInformation").Select(filterExp,
sortExp)

For count = 0 To myTable.Rows.Count
Dim changeDate As DateTime =
Convert.ToDateTime(myData.Tables("Information").Ro ws(count).Item(count
+ 1))

changeDate = changeDate.AddYears(1).ToShortDateString()

myData.Tables("Information").Rows(count).Item(coun t +
1).Add(changeDate).
I am getting an error on this line, Public member 'Add' on type
'String' not found.

Next

I have tried using ToString() and that does not work either.

I know there are easier ways of doing this, but just something I am
messing around with. Any help would be appreciated.

Scott Moore

Aug 15 '06 #1
6 1485
Samoore33,

An XML doc and an XML dataset are not direct the same thing.

A dataset does not contain attributes but only elements. (You can convert
mostly a XML doc to a dataset).

Those elements are from the valid Net types. In this case it should it be
than of the type DateTime.

If that is as I wrote than it simple.
\\\
For each row as datarow in YourDataTable.rows
row("YourDateTimeColumn") = row("YourDateTimeColumn").AddYears(1)
next
///

http://msdn2.microsoft.com/en-us/lib....addyears.aspx

I hope this helps,

Cor

"samoore33" <sa*******@gmail.comschreef in bericht
news:11*********************@p79g2000cwp.googlegro ups.com...
>I have created a xml doc that stores dates. On the first of the year I
want to upload the xml doc into a dataset and then loop through it
adding one year to those dates.

This is what I have attempted.

myData.ReadXml("this.xml")
myTable = myData.Tables("myInformation")

myRow = myData.Tables("myInformation").Select(filterExp,
sortExp)

For count = 0 To myTable.Rows.Count
Dim changeDate As DateTime =
Convert.ToDateTime(myData.Tables("Information").Ro ws(count).Item(count
+ 1))

changeDate = changeDate.AddYears(1).ToShortDateString()

myData.Tables("Information").Rows(count).Item(coun t +
1).Add(changeDate).
I am getting an error on this line, Public member 'Add' on type
'String' not found.

Next

I have tried using ToString() and that does not work either.

I know there are easier ways of doing this, but just something I am
messing around with. Any help would be appreciated.

Scott Moore

Aug 15 '06 #2
Cor,

I tried that, I get the error of Public member 'AddYears' on type
'String' not found. I am going to search for the error and see what I
can find. Below is the code I am using.

For the xml doc, I am using myDataSet.ReadXml("myXml.xml") to bring
upload the xml doc into my dataset. Not sure if that makes a
difference.

Dim myData As New DataSet("myXML")
Dim myTable As DataTable
Dim r As DataRow
Dim c As DataColumn

myData.ReadXml("myXml.xml")
myTable = myData.Tables("myInfo")

For Each r In myTable.Rows
r("Date") = r("Date").AddYears(1)
Next

Cor Ligthert [MVP] wrote:
Samoore33,

An XML doc and an XML dataset are not direct the same thing.

A dataset does not contain attributes but only elements. (You can convert
mostly a XML doc to a dataset).

Those elements are from the valid Net types. In this case it should it be
than of the type DateTime.

If that is as I wrote than it simple.
\\\
For each row as datarow in YourDataTable.rows
row("YourDateTimeColumn") = row("YourDateTimeColumn").AddYears(1)
next
///

http://msdn2.microsoft.com/en-us/lib....addyears.aspx

I hope this helps,

Cor

"samoore33" <sa*******@gmail.comschreef in bericht
news:11*********************@p79g2000cwp.googlegro ups.com...
I have created a xml doc that stores dates. On the first of the year I
want to upload the xml doc into a dataset and then loop through it
adding one year to those dates.

This is what I have attempted.

myData.ReadXml("this.xml")
myTable = myData.Tables("myInformation")

myRow = myData.Tables("myInformation").Select(filterExp,
sortExp)

For count = 0 To myTable.Rows.Count
Dim changeDate As DateTime =
Convert.ToDateTime(myData.Tables("Information").Ro ws(count).Item(count
+ 1))

changeDate = changeDate.AddYears(1).ToShortDateString()

myData.Tables("Information").Rows(count).Item(coun t +
1).Add(changeDate).
I am getting an error on this line, Public member 'Add' on type
'String' not found.

Next

I have tried using ToString() and that does not work either.

I know there are easier ways of doing this, but just something I am
messing around with. Any help would be appreciated.

Scott Moore
Aug 15 '06 #3
Samoore,

Your date is probably in a string format. However, you can than probably
still slightly changed use this.

myData.ReadXml("myXml.xml")
myTable = myData.Tables("myInfo")
For Each r In myTable.Rows
r("Date") = CDate(r("Date")).AddYears(1).ToShortString ' or whatever
Next

Can you try that one,

I hope this helps,

Cor

Aug 16 '06 #4
Cor,

Same error. I am not even sure if this is possible. This is just
something I have been messing with, but want to try to get it to work.
I will keep searching for answers. Not sure what else to do though.

I know the easy way of doing this is storing things in a Database, but
figured that was the easy way, so I started messing with the xml into a
DataSet.

Samoore

Cor Ligthert [MVP] wrote:
Samoore,

Your date is probably in a string format. However, you can than probably
still slightly changed use this.

myData.ReadXml("myXml.xml")
myTable = myData.Tables("myInfo")
For Each r In myTable.Rows
r("Date") = CDate(r("Date")).AddYears(1).ToShortString ' or whatever
Next

Can you try that one,

I hope this helps,

Cor
Aug 16 '06 #5
Samoore,

I made a test it works as a charm (I did only look in your code to that add
part)

\\\
Dim dt As New DataTable
Dim dc As New DataColumn("Date", GetType(System.String))
dt.Columns.Add(dc)
For i As Integer = 1 To 12
dt.LoadDataRow(New Object() {"1-" & i.ToString & "-2005"}, True)
'my culture uses dd-MM-yyyy
Next
For Each r As DataRow In dt.Rows
r("Date") = CDate(r("Date")).AddYears(1).ToString("dd-MM-yyyy")
' or whatever
Next
MessageBox.Show(dt.Rows(11)("Date").ToString) 'shows 01-12-2006
///
I hope this helps,

Cor

"samoore33" <sa*******@gmail.comschreef in bericht
news:11**********************@75g2000cwc.googlegro ups.com...
Cor,

Same error. I am not even sure if this is possible. This is just
something I have been messing with, but want to try to get it to work.
I will keep searching for answers. Not sure what else to do though.

I know the easy way of doing this is storing things in a Database, but
figured that was the easy way, so I started messing with the xml into a
DataSet.

Samoore

Cor Ligthert [MVP] wrote:
>Samoore,

Your date is probably in a string format. However, you can than probably
still slightly changed use this.

myData.ReadXml("myXml.xml")
myTable = myData.Tables("myInfo")
For Each r In myTable.Rows
r("Date") = CDate(r("Date")).AddYears(1).ToShortString ' or
whatever
Next

Can you try that one,

I hope this helps,

Cor

Aug 16 '06 #6
Cor,

Thanks, that worked. I appreciate the help.

Samoore

Cor Ligthert [MVP] wrote:
Samoore,

I made a test it works as a charm (I did only look in your code to that add
part)

\\\
Dim dt As New DataTable
Dim dc As New DataColumn("Date", GetType(System.String))
dt.Columns.Add(dc)
For i As Integer = 1 To 12
dt.LoadDataRow(New Object() {"1-" & i.ToString & "-2005"}, True)
'my culture uses dd-MM-yyyy
Next
For Each r As DataRow In dt.Rows
r("Date") = CDate(r("Date")).AddYears(1).ToString("dd-MM-yyyy")
' or whatever
Next
MessageBox.Show(dt.Rows(11)("Date").ToString) 'shows 01-12-2006
///
I hope this helps,

Cor

"samoore33" <sa*******@gmail.comschreef in bericht
news:11**********************@75g2000cwc.googlegro ups.com...
Cor,

Same error. I am not even sure if this is possible. This is just
something I have been messing with, but want to try to get it to work.
I will keep searching for answers. Not sure what else to do though.

I know the easy way of doing this is storing things in a Database, but
figured that was the easy way, so I started messing with the xml into a
DataSet.

Samoore

Cor Ligthert [MVP] wrote:
Samoore,

Your date is probably in a string format. However, you can than probably
still slightly changed use this.

myData.ReadXml("myXml.xml")
myTable = myData.Tables("myInfo")
For Each r In myTable.Rows
r("Date") = CDate(r("Date")).AddYears(1).ToShortString ' or
whatever
Next

Can you try that one,

I hope this helps,

Cor
Aug 16 '06 #7

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

Similar topics

3
by: PAUL EDWARDS | last post by:
I have a windows form that is bound to a datatable. In VB6 I could just update the field contents and it would be updated in the database, however if I update the text property of the control from...
9
by: jaYPee | last post by:
I have search a lot of thread in google newsgroup and read a lot of articles but still i don't know how to update the dataset that has 3 tables. my 3 tables looks like the 3 tables from...
2
by: Richard | last post by:
Hi, I have 1 dataset with 2 tables (Table1 as parent, Table2 as Child), 1 row in both the tables. I am updating it with a transaction. First parent then child. When child update fails, it raise...
5
by: PAUL | last post by:
Hello, I have 2 tables with a relationship set up in the dataset with vb ..net. I add a new record to the parent table then edit an existing child record to have the new parent ID. However when I...
8
by: Zorpiedoman | last post by:
I keep getting a concurrency exception the second time I make a change and attempt to update a dataadapter. It appears this is by design, so there must be something I can do to avoid it. ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.