Connecting Tech Pros Worldwide Help | Site Map

DAO Connectionless Recordset?

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 17th, 2006, 03:45 PM
darkforcesjedi
Guest
 
Posts: n/a
Default DAO Connectionless Recordset?

Creating a connectionless recordset in ADO is simple enough, but how do
you do it in DAO? I want a recordset stored in memory so I can
filter/sort it easily. If I create a table I can make it work, but I
don't want to have to read/write everything from/to disk every time I
need to use the data.

I tried:

Dim r As DAO.Recordset, tdf As DAO.TableDef

Set tdf = CurrentDb.CreateTableDef("tmp", dbHiddenObject)
With tdf.Fields
.Append tdf.CreateField("TypeID", dbLong)
.Append tdf.CreateField("Minor_ID", dbLong)

End With

'ERROR 3420 "Object invalid or no longer set"
Set r = tdf.OpenRecordset

r.AddNew
r.Fields("TypeID") = 1
r.Fields("Minor_ID") = 7
r.Update

r.Close
Set r = Nothing
Set tdf = Nothing


  #2  
Old July 17th, 2006, 04:05 PM
Lyle Fairfield
Guest
 
Posts: n/a
Default Re: DAO Connectionless Recordset?


darkforcesjedi wrote:
Quote:
Creating a connectionless recordset in ADO is simple enough, but how do
you do it in DAO? I want a recordset stored in memory so I can
filter/sort it easily. If I create a table I can make it work, but I
don't want to have to read/write everything from/to disk every time I
need to use the data.
>
I tried:
>
Dim r As DAO.Recordset, tdf As DAO.TableDef
>
Set tdf = CurrentDb.CreateTableDef("tmp", dbHiddenObject)
With tdf.Fields
.Append tdf.CreateField("TypeID", dbLong)
.Append tdf.CreateField("Minor_ID", dbLong)
>
End With
>
'ERROR 3420 "Object invalid or no longer set"
Set r = tdf.OpenRecordset
>
r.AddNew
r.Fields("TypeID") = 1
r.Fields("Minor_ID") = 7
r.Update
>
r.Close
Set r = Nothing
Set tdf = Nothing
Quote:
>From many years ago (the notion is that Transactions will make this
recordset never saved to disk):

Function VirtualDAORecordSet()
Dim TableName As String
Dim Counter As Long
Dim Rcs As DAO.Recordset
With DBEngine
.BeginTrans
With .Workspaces(0)(0)
On Error GoTo CreateTableErr:
TableName = "tblTemp" & CStr(Counter)
.Execute "CREATE TABLE " & TableName & "(fldHoliday TEXT
CONSTRAINT AlphaHoliday UNIQUE);"
Set Rcs = .OpenRecordset(TableName, dbOpenTable)
With Rcs
.AddNew
.Fields("fldHoliday") = "Xerxes Day"
.Update
.AddNew
.Fields("fldHoliday") = "Anaximander Day"
.Update
.AddNew
.Fields("fldHoliday") = "Plato Day"
.Update
.Index = "AlphaHoliday"
.MoveFirst
MsgBox .Fields("fldHoliday") 'Anixamder Day
.MoveNext
MsgBox .Fields("fldHoliday") 'Plato Day
.MoveLast
MsgBox .Fields("fldHoliday") 'Xerxes Day
.Close
End With
End With
End With
VirtualDAORecordSetExit:
Set Rcs = Nothing
DBEngine.Rollback
Exit Function
CreateTableErr:
With Err
If .Number = 3010 Then
Counter = Counter + 1
TableName = "tblTemp" & CStr(Counter)
Resume
Else
MsgBox .Number & " " & .Description
Resume VirtualDAORecordSetExit
End If
End With
End Function

  #3  
Old July 17th, 2006, 11:15 PM
David W. Fenton
Guest
 
Posts: n/a
Default Re: DAO Connectionless Recordset?

"darkforcesjedi" <andrew.mallner@pgnmail.comwrote in
news:1153151508.366449.151670@m73g2000cwd.googlegr oups.com:
Quote:
Creating a connectionless recordset in ADO is simple enough, but
how do you do it in DAO?
No. Disconnected recordsets do not exist in DAO and probably never
will. You have to use a table or a transaction (on real tables that
is then rolled back).

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
  #4  
Old July 18th, 2006, 02:55 AM
Tom van Stiphout
Guest
 
Posts: n/a
Default Re: DAO Connectionless Recordset?

On 17 Jul 2006 09:05:10 -0700, "Lyle Fairfield"
<lylefairfield@aim.comwrote:

Anaximander? That's kind-a obscure. Scolars don't even agree on his
birth year, let alone birth date. And no women in the list (or did you
just provide a fragment of your code)?
Your transaction idea is just as obscure. It probably works, but would
you want it to?

-Tom.

Quote:
>
>darkforcesjedi wrote:
Quote:
>Creating a connectionless recordset in ADO is simple enough, but how do
>you do it in DAO? I want a recordset stored in memory so I can
>filter/sort it easily. If I create a table I can make it work, but I
>don't want to have to read/write everything from/to disk every time I
>need to use the data.
>>
>I tried:
>>
> Dim r As DAO.Recordset, tdf As DAO.TableDef
>>
> Set tdf = CurrentDb.CreateTableDef("tmp", dbHiddenObject)
> With tdf.Fields
> .Append tdf.CreateField("TypeID", dbLong)
> .Append tdf.CreateField("Minor_ID", dbLong)
>>
> End With
>>
> 'ERROR 3420 "Object invalid or no longer set"
> Set r = tdf.OpenRecordset
>>
> r.AddNew
> r.Fields("TypeID") = 1
> r.Fields("Minor_ID") = 7
> r.Update
>>
> r.Close
> Set r = Nothing
> Set tdf = Nothing
>
Quote:
>>From many years ago (the notion is that Transactions will make this
>recordset never saved to disk):
>
>Function VirtualDAORecordSet()
Dim TableName As String
Dim Counter As Long
Dim Rcs As DAO.Recordset
With DBEngine
.BeginTrans
With .Workspaces(0)(0)
On Error GoTo CreateTableErr:
TableName = "tblTemp" & CStr(Counter)
.Execute "CREATE TABLE " & TableName & "(fldHoliday TEXT
>CONSTRAINT AlphaHoliday UNIQUE);"
Set Rcs = .OpenRecordset(TableName, dbOpenTable)
With Rcs
.AddNew
.Fields("fldHoliday") = "Xerxes Day"
.Update
.AddNew
.Fields("fldHoliday") = "Anaximander Day"
.Update
.AddNew
.Fields("fldHoliday") = "Plato Day"
.Update
.Index = "AlphaHoliday"
.MoveFirst
MsgBox .Fields("fldHoliday") 'Anixamder Day
.MoveNext
MsgBox .Fields("fldHoliday") 'Plato Day
.MoveLast
MsgBox .Fields("fldHoliday") 'Xerxes Day
.Close
End With
End With
End With
>VirtualDAORecordSetExit:
Set Rcs = Nothing
DBEngine.Rollback
Exit Function
>CreateTableErr:
With Err
If .Number = 3010 Then
Counter = Counter + 1
TableName = "tblTemp" & CStr(Counter)
Resume
Else
MsgBox .Number & " " & .Description
Resume VirtualDAORecordSetExit
End If
End With
>End Function
  #5  
Old July 18th, 2006, 03:15 AM
Lyle Fairfield
Guest
 
Posts: n/a
Default Re: DAO Connectionless Recordset?


Tom van Stiphout wrote:
Quote:
On 17 Jul 2006 09:05:10 -0700, "Lyle Fairfield"
<lylefairfield@aim.comwrote:
>
Anaximander? That's kind-a obscure. Scolars don't even agree on his
birth year, let alone birth date. And no women in the list (or did you
just provide a fragment of your code)?
Your transaction idea is just as obscure. It probably works, but would
you want it to?
So sorry ... it was a typo for Anixemenes.

I don't think I'd want to. I have used temporary tables within
transactions when dealing with some ghastly non-normalized genealogical
tables where the calculations were very intensive ... follwing back
parents; to simplify this I created the temp tables, indexed them and
scanned through them, writing and ftping up html files for each person
.... I do think this simplified things by giving me two or three
standard tables that were designed just for this modules needs. By
indexing these I could find a son/daughter/second wife/whatever pdq ...
even counting creating the tables and indexes the thing ran several
hundred times faster than using the disorganized data. Of course the
tables were never saved ...also of course, Access itself had no
knowledge of them, even during their existence.

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.