Re: Database + dll




"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)
>>>
>
>


.



Relevant Pages

  • Error message when opening a recordset with a strem containing xml
    ... I have a problem when trying to open a recordset with a stream including xml ... System.String schemaText = null; ...
    (microsoft.public.data.ado)
  • Re: Database + dll
    ... You can include an XML or ADTG persisted Recordset with the ... > copied to a stream first anyway (not that the recordset would alter the ... > It's a simple matter of creating a custom resource type from an XML file at ...
    (microsoft.public.vb.database.ado)
  • Re: Recordset load XML
    ... file, if you are using a version of ADO that supports the Stream object, you ... new Recordset ... Recordset return so I save the RecordSet to an XML string: ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Trouble recreating ADO recordset from XML
    ... I use rst->Save to persist the data into a _Stream object. ... Meant to add, when opening a recordset on a persisted source, those options ... have you looked at the XML? ...
    (microsoft.public.data.ado)
  • Using XSD stored in assembly resource with includes
    ... I am trying to validate an XML file against an XSD that is stored in the ... I can get it to work as long as the XSD ... the resource stream based on the uri and return the stream. ...
    (microsoft.public.dotnet.xml)