Hi,
In my application I have been using an Access database (mdb files, 2003 format I think). All the data accessing is done completely manually, using code such as this:
vb.net Code:
Public Sub ExecuteNonQuery(ByVal sql As String, Optional ByVal params As Parameters = Nothing) If Me.IsConnected Then Using cmd As New OleDbCommand cmd.Connection = Me.Connection cmd.CommandType = CommandType.Text cmd.CommandText = sql cmd.Parameters.Clear() If params IsNot Nothing Then For Each key As String In params.Keys cmd.Parameters.AddWithValue(key, params.Item(key)) Next End If cmd.ExecuteNonQuery() End Using Else Throw New Exception(strNO_DB_CONNECTION) End If End Sub
Basically, I made a class Database, with these methods (also ExecuteScalar, ExecuteReader, Connect, Disconnect, etc). Then I make a Manager class for every table and an Entity class representing one entry in the database. The Entity class is basically just a list of properties corresponding to the fields in the table, while the Manager class loads and saves Entity classes like this:
vb.net Code:
Public Function Load(ByVal sql As String, Optional ByVal params As Parameters = Nothing) As clsWorkflowItemCollection Dim result As New clsWorkflowItemCollection() Me.Database.Connect() Using reader = Me.Database.ExecuteReader(sql, params) While reader.Read() ' The FromReader method sets the properties of a WorkflowListItem instance to the values in the data reader result.Add(clsWorkflowListItem.FromReader(reader)) End While End Using Me.Database.Disconnect() Return result End Function
What I'm trying to say basically is that I'm not using any of the built in data access things. I never have and I feel no need for them, this works just fine for me and I like the amount of control I have over it.
Anyway, I would now like to start using XML files instead of an Access database. I am wondering how hard it would be to convert my code to use XML instead of a database. I searched around but all I can find is code that does use the VS built in data access things (sorry not really sure what it's called lol).
What would I need to change? For example, I'm now using an OleDbConnection object. I'm sure that won't work for XML files, will it? Is there some kind of alternative for XML files (XmlDbConnection?)
Basically I want to know how much trouble it would be. If it means a WHOLE lot of work to change everything, I'm not doing it. I'd rather use XML files but it's not absolutely required.
Thanks!




)
Reply With Quote