Re: Database + dll
- From: "Mark J. McGinty" <mmcginty@xxxxxxxxxxxxxxx>
- Date: Tue, 12 Jul 2005 16:33:54 -0700
"William (Bill) Vaughn" <billvaRemoveThis@xxxxxxxxxx> wrote in message
news:%23$ivyMyhFHA.1968@xxxxxxxxxxxxxxxxxxxxxxx
> Sure. You can include an XML or ADTG persisted Recordset with the
> application. ADO does not need any "engine" to read these files to
> rehydrate a Recordset. It would not be "included" in the DLL. DLLs are
> placed in read-only memory--you would never be permitted to write to a
> code segment.
XML can be compiled into a DLL as a resource, and loaded into a recordset
from there. Once a recordset has been opened on persistance provider XML it
has no need (or inherent facility) to rewrite the memory in which the XML
was stored... actually if it isn't in a stand-alone file it would have to be
copied to a stream first anyway (not that the recordset would alter the
original stream either.)
It's a simple matter of creating a custom resource type from an XML file at
design time, then at runtime, opening the resource, copying it to a stream,
and passing the stream to recordset.open
This is the function I use:
' First attempts to open a file in the CWD named in ID. If that fails
' it uses a resource included at compile time. By convention the
' resource id is in the form filename.xml, and the custom resource
' name is XMLDATA.
'
Function OpenResourceRecordset(ID) As ADODB.Recordset
Set OpenResourceRecordset = Nothing
Dim rs As ADODB.Recordset
Dim s As ADODB.Stream
Dim buf As String
Set rs = New ADODB.Recordset
Set s = New ADODB.Stream
s.Mode = adModeReadWrite
s.Type = adTypeText
s.Charset = "unicode"
s.Open
On Error Resume Next
Err.Clear
s.LoadFromFile App.Path & "\" & ID
If (Err.Number = 0) And (s.Size > 0) Then
rs.Open s
End If
If (Err.Number > 0) Or (rs.State = 0) Then
buf = LoadResData(ID, "XMLDATA")
' for some really stupid reason, the vb resource tool
' prefixes each custom item with a question mark
'
buf = Right(buf, Len(buf) - 1)
s.Close
s.Open
s.WriteText buf
s.Position = 0
rs.Open s
End If
If rs.State > 0 Then Set OpenResourceRecordset = rs
Set rs = Nothing
s.Close
Set s = Nothing
End Function
-Mark
> --
> ____________________________________
> William (Bill) Vaughn
> Author, Mentor, Consultant
> Microsoft MVP
> www.betav.com/blog/billva
> www.betav.com
> Please reply only to the newsgroup so that others can benefit.
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
> __________________________________
>
> "Joseph" <Joseph@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> news:27600340-6C74-41CE-8613-EC583914F73F@xxxxxxxxxxxxxxxx
>>I am trying to build an app that will be totally independent from a
>>database,
>> text file etc. I was told that it is possible to build such an app
>> without an
>> external data source such as Access, SQL Server, or Text file. I am using
>> one
>> table worth of data for this app. Any ideas on how this might be
>> accomplished?
>>
>> "Paul Clement" wrote:
>>
>>> On Tue, 12 Jul 2005 10:21:04 -0700, Joseph
>>> <Joseph@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
>>>
>>> ¤ I want to know if it is possible to store data in a dll, and if so can
>>> anyone
>>> ¤ direct me to how I can go about doing this (Example or tutorial site
>>> would be
>>> ¤ great). I would like to create my own dll to accomplish this. Thanks
>>>
>>> DLLs are code libraries. There are not designed for the storage of data.
>>>
>>>
>>> Paul
>>> ~~~~
>>> Microsoft MVP (Visual Basic)
>>>
>
>
.
- Follow-Ups:
- Re: Database + dll
- From: Joseph
- Re: Database + dll
- References:
- Database + dll
- From: Joseph
- Re: Database + dll
- From: Paul Clement
- Re: Database + dll
- From: Joseph
- Re: Database + dll
- From: William \(Bill\) Vaughn
- Database + dll
- Prev by Date: Re: DataGrid - can't update a cell - VB6, SQL 2000
- Next by Date: Re: DataGrid - can't update a cell - VB6, SQL 2000
- Previous by thread: Re: Database + dll
- Next by thread: Re: Database + dll
- Index(es):
Relevant Pages
|