I wasn't reccomending any particular method. I would agree that database
properties and tables are better because they are carried with the database.
If I was storing more complicated objects e.g. I wanted to persist the state
of a class module (or form) then XML may well be the way to go, personally
though I would look at tables or property bags.
The advantage of a property bag is that you can store it whereever you want
so you can persist it to a file, or the registry or a database field. They
are less easy to "crack" than XML as well.
You could use an ADO stream and persist that to a field in a table as well.
e.g.
(BTW this is a horrible cludgy piece of code which I've knocked up because
I've only just thought of this as a method, so no digs on the style please)
Function ADOStream()
Dim rs1 As ADODB.Recordset
Dim rs2 As ADODB.Recordset
Dim stm As ADODB.Stream
Dim strTest As String
Set rs1 = New ADODB.Recordset
Set rs2 = New ADODB.Recordset
Set stm = New ADODB.Stream
rs1.Open "SELECT * FROM Customers", "Provider=sqloledb;" & _
"Data Source=wmpsdeterry3;Initial Catalog=Northwind;" & _
"User Id=sa;Password=;""", adOpenStatic, adLockReadOnly, adCmdText
rs1.Save stm, adPersistXML
strTest = stm.ReadText
rs2.Open "SELECT * FROM tblPersist WHERE 1=0", CurrentProject.Connection,
adOpenDynamic, adLockOptimistic
With rs2
.AddNew
.Fields("persist").AppendChunk strTest
.Update
End With
End Function
Function GetItBack()
Dim rs1 As ADODB.Recordset
Dim rs2 As ADODB.Recordset
Dim stm As ADODB.Stream
Dim strTest As String
Set rs1 = New ADODB.Recordset
Set rs2 = New ADODB.Recordset
Set stm = New ADODB.Stream
rs2.Open "SELECT * FROM tblPersist WHERE [id]=1",
CurrentProject.Connection
With rs2.Fields("persist")
strTest = .GetChunk(.ActualSize)
End With
stm.Open
Call stm.WriteText(strTest)
stm.Position = 0
rs1.Open stm
End Function
--
Terry Kreft
<ji********@compumarc.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
Terry Kreft wrote: The main thing is persistence.
If you are simply persisting static values then it doesn't matter what
you
use.
I you are persisting values which can be altered by the user (i.e. user
settings) then you need to persist to something which can be written to.
Typical examples include:-
Data tables
Ini Files
Plain text files
Registry (especially using GetSetting/SaveSetting)
Database properties
I think the Data tables and Database properties have an advantage over
the others since the changes are contained within the mdb file itself.
What do you think about storing information in an XML file for more
complicated objects?
James A. Fortune
I think in (american) football there's a mistaken idea that you can get
by with average offensive and defensive linemen if you have a star
quarterback, star receivers and a star running back. I have lots of
patience, rather, for any team that picks linemen high in the draft.
Those offensive linemen will turn average QB's, running backs and
receivers into stars. Those defensive linemen will turn the other
team's QB's, running backs and receivers into losers.