On Tue, 3 Jan 2006 19:38:59 +0100, "Cor Ligthert [MVP]"
<no************@planet.nl> wrote:
DGK,
Of course, I can't use Access to look at it in a pinch. But maybe I
can. Access can probably import a database from XML, and if not, it
should be able to.
For the single user database as you want probably nothing.
Be aware that you keep good track that you only delete an XML file when you
are sure that it is good written. (Not overwrite it, however by instance
first rename it, write it and after that delete the renamed file)
If it becomes really huge, than it will probably will need to much reading
and writing time.
In the samples on our website is probably one that fits. By instance the one
about the images, that covers without that safe storing I talk about above
probably your question.
http://www.vb-tips.com/default.aspx?...6-38b5a2f7fdf0
Cor
It won't get that huge.
I knew I did this before. Here's creating the DB:
Dim RSdb As DataSet
RSdb = New DataSet("RSData")
' Manufacturers Table
Dim RSTB_Man As DataTable = RSdb.Tables.Add("Manufacturers")
Dim ManCol As DataColumn = RSTB_Man.Columns.Add("PriKey",
Type.GetType("System.Int32"))
RSTB_Man.PrimaryKey = New DataColumn() {ManCol}
RSTB_Man.Columns("PriKey").AutoIncrement = True
RSTB_Man.Columns.Add("Name", Type.GetType("System.String"))
RSTB_Man.Columns("Name").MaxLength = 40
RSTB_Man.Columns.Add("ContactURL",
Type.GetType("System.String"))
RSTB_Man.Columns("ContactURL").MaxLength = 60
RSTB_Man.Columns.Add("ContactPhone",
Type.GetType("System.String"))
RSTB_Man.Columns("ContactPhone").MaxLength = 20
' Vendors Table
Dim RSTB_Vendors As DataTable = RSdb.Tables.Add("Vendors")
Dim VenCol As DataColumn = RSTB_Vendors.Columns.Add("PriKey",
Type.GetType("System.Int32"))
RSTB_Vendors.PrimaryKey = New DataColumn() {VenCol}
RSTB_Vendors.Columns("PriKey").AutoIncrement = True
RSTB_Vendors.Columns.Add("Name",
Type.GetType("System.String"))
RSTB_Vendors.Columns("Name").MaxLength = 40
RSTB_Vendors.Columns.Add("ContactURL",
Type.GetType("System.String"))
RSTB_Vendors.Columns("ContactURL").MaxLength = 60
RSTB_Vendors.Columns.Add("ContactPhone",
Type.GetType("System.String"))
RSTB_Vendors.Columns("ContactPhone").MaxLength = 20
Add a little data:
Dim MyMan As System.Data.DataTable =
RSdb.Tables("Manufacturers")
Dim ManRow As System.Data.DataRow = MyMan.NewRow
ManRow("Name") = "Linksys"
MyMan.Rows.Add(ManRow)
ManRow = MyMan.NewRow
ManRow("Name") = "Belkin"
MyMan.Rows.Add(ManRow)
Save it to disk when done - but do save previous version first!:
Try
Dim MyPath As String = AppPath
If MyPath.Length > 0 And Not MyPath.EndsWith("\") Then
MyPath += "\"
End If
db.WriteXml(MyPath & "RSData.xml",
XmlWriteMode.WriteSchema)
Catch Badthing As Exception
MessageBox.Show("Failed to save dataset: " &
Badthing.Message, "Save Error", MessageBoxButtons.OK,
MessageBoxIcon.Warning)
End Try
And of course, read it in next time:
RSdb = New DataSet ' better instantiate it first
RSdb.ReadXml(MyPath & "RSData.xml", XmlReadMode.ReadSchema)