Re: Can anybody show me how to open up a DAO connection to an Acce

From: Brendan Reynolds (brenreyn)
Date: 10/21/04


Date: Thu, 21 Oct 2004 13:59:00 +0100

I'm afraid I don't know why you're still not getting the correct record
count. As for the other questions ...

ADODB recordsets don't have an Edit method, but you don't need one, provided
the recordset is not read only you can edit field values just by moving to
the record and assigning the new values to the fields (as in the example I
previously posted).

The Update method works as in DAO, but the behaviour if you *don't* call
Update is different. In DAO, if you change data then move off the record
without calling Update, the change is abandoned. In ADO, the change is
saved.

Yes, you can refer to fields by ordinal number as well as by name. Don't
forget that this is zero-based, so rst.Fields(1) is the second field in the
recordset.

-- 
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com
The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
"Cliff Sutton" <CliffSutton@discussions.microsoft.com> wrote in message 
news:5E8E007E-7CDC-4D6D-BE5E-240B13BB5767@microsoft.com...
> Thank you very much this is a great help, the only thing is I keep 
> getting -1
> for the recordcount when I know it has aprox 6000 records.
>
> Cliff
> Also can you do as in DAO
>
> rst.edit     or rst.update
> and change or set rst(1)="blabla" as an example?
>
>
> "Brendan Reynolds" wrote:
>
>> The default recordset type in ADO is a forward-only, read-only recordset.
>> You need to specify some of the optional arguments to get a scrollable,
>> read-write recordset. In some circumstances you may need to do a 
>> .MoveLast
>> before you can get an accurate record count. Here's an example that opens 
>> a
>> forward and backward scrollable, updateable recordset ...
>>
>> Public Sub ScrollWrite()
>>
>>     Dim cnn As ADODB.Connection
>>     Dim rst As ADODB.Recordset
>>
>>     'Access-specific, don't try to use this in VB.
>>     Set cnn = CurrentProject.Connection
>>
>>     Set rst = New ADODB.Recordset
>>     With rst
>>         .ActiveConnection = cnn
>>         .CursorType = adOpenDynamic
>>         .LockType = adLockOptimistic
>>         .Source = "SELECT * FROM Products"
>>         .Open
>>         .MoveLast
>>         .MoveFirst
>>         .Fields("ProductName") = .Fields("ProductName") & "Y"
>>         .Update
>>         .Close
>>     End With
>>
>>
>> End Sub
>>
>> -- 
>> Brendan Reynolds (MVP)
>> http://brenreyn.blogspot.com
>>
>> The spammers and script-kiddies have succeeded in making it impossible 
>> for
>> me to use a real e-mail address in public newsgroups. E-mail replies to
>> this post will be deleted without being read. Any e-mail claiming to be
>> from brenreyn at indigo dot ie that is not digitally signed by me with a
>> GlobalSign digital certificate is a forgery and should be deleted without
>> being read. Follow-up questions should in general be posted to the
>> newsgroup, but if you have a good reason to send me e-mail, you'll find
>> a useable e-mail address at the URL above.
>>
>>
>> "Cliff Sutton" <CliffSutton@discussions.microsoft.com> wrote in message
>> news:67BF8463-4DB0-469E-9DA3-A533E1CDBFE5@microsoft.com...
>> >I have been using DAO in VB6 and I have been struggling with ADO, I 
>> >cannot
>> > get the recordcount to give how many records, or the moveprevious to 
>> > work
>> > or
>> > the movelast. The commands appear but they do not work. Can anybody 
>> > help
>> >
>> > -- 
>> > Clifford Sutton
>>
>>
>> 


Relevant Pages

  • Re: DAO MUCH faster than ADO in this test
    ... DAO is well-known to be faster than ADO. ... Of course the DAO loop ran faster than the SQL loop; ... advantage of a table-type recordset, which only works on local tables. ... Dim starttime As Single, finishtime As Single ...
    (microsoft.public.access.modulesdaovba)
  • Re: Is it possible to link via ADODB from an Access 2K .mdb file?
    ... to decide if we want to rewrite it all by just allowing record locking in DAO ... UPDATEs instead of recordset updates - do you mean I should use ADO commands ... recordset based on SQL Server data, ...
    (microsoft.public.sqlserver.clients)
  • Re: Me.Recordset -> DoCmd.RunSQL "UPDATE ...............
    ... DAO is the preferred library for interacting with Jet database engine. ... primary method by which data are manipulated in ACCESS databases since ... >> the form based on DAO recordset SQL statement: ... >> form's Recordsource to the SQL statement itself ("SELECT * FROM ...
    (microsoft.public.access.modulesdaovba)
  • Re: Datensatz in Recordset finden
    ... Dein Hinweis auf .FindFirst lässt nur vermuten, dass Du mit DAO arbeitest. ... > ich brauche ja mein Recordset Objekt so wie es ist. ... statt mit DAO mit ADO zu arbeiten. ... > Ansprechpartner. ...
    (microsoft.public.de.vb.datenbank)
  • Re: FindFirst error
    ... That was fine in Access 97, when there was only one kind of Recordset ... DAO recordsets and ADODB recordsets. ... you have both the DAO and ADO object libraries referenced. ... I suggest you simply drop the reference to ADO entirely. ...
    (microsoft.public.access.modulesdaovba)

Loading