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

ADO.NET: Updating data

P: n/a
Hi,

I've only got a typical crappy Microsoft book about ADO.NET (MSPRESS
!"(#&/()&# you for mixing manual written code and suddenly adding
designtime controls and wizards for updating data)

I've got a function that is just for learning purposes the naming convention
is bad and such since it's a mix of my conventions and MS Press conventions.
I work with XML files in a database guy's approach. I've managed to create a
schema for my table and i think i know how to add the data correctly but i
can't manage to update my data back to my DataSet and write the DataSet as
an XMLFile.

Would anyone be so kind to help me out with a updatetable thingie ?

My Code fails on the AcceptChanges which i suppose is because my DataRow
isn't written back to the DataSet but how do i do that ?

Public Function doCreateNewXmlfile()
Dim ds As New DataSet
Dim col As DataColumn
Dim oDataRow As DataRow

'Create the table structure.
With ds.Tables.Add("Routers")
col = .Columns.Add("IPAddr", GetType(String))
col.MaxLength = 15
col = .Columns.Add("HostName", GetType(String))
col.MaxLength = 90
col = .Columns.Add("LogFileName", GetType(String))
col.MaxLength = 30
End With
' Save our schema representing our table structure
Dim oFileStream As New
System.IO.FileStream(Me.setXmlIpTableFileSchemaNam e, FileMode.Create)
ds.WriteXmlSchema(oFileStream)
oFileStream.Close()
oFileStream = Nothing

' Create some data in our xmldatabase
Dim row As DataRow = ds.Tables("Routers").NewRow
row("IPAddr") = "192.168.1.1"
row("HostName") = "tower"
row("LogFileName") = "tower_Log"

row.AcceptChanges()
oFileStream = New System.IO.FileStream(Me.setXmlIpTableFileName,
FileMode.Create)
ds.WriteXml(oFileStream)
oFileStream.Close()
oFileStream = Nothing
End Function

Thanks a lot
/Kai
Nov 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
* "Kai Thorsrud" <ka******@thispartgoesaways.start.no> scripsit:
I've only got a typical crappy Microsoft book about ADO.NET (MSPRESS
!"(#&/()&# you for mixing manual written code and suddenly adding
designtime controls and wizards for updating data)


ADO.NET group:

<news://msnews.microsoft.com/microsoft.public.dotnet.framework.adonet>

Web interface:

<http://msdn.microsoft.com/newsgroups/default.asp?url=/newsgroups/loadframes.asp?icp=msdn&slcid=us&newsgroup=microso ft.public.dotnet.framework.adonet>

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.