Re: Can anybody show me how to open up a DAO connection to an Acce
From: Brendan Reynolds (brenreyn)
Date: 10/21/04
- Next message: rmsterling: "VB6-ADO-COM-ODBC-INFORMIX : Problem running query. SQL State 37000"
- Previous message: Brendan Reynolds: "Re: Error - Could not find installable ISAM"
- In reply to: Cliff Sutton: "Re: Can anybody show me how to open up a DAO connection to an Acce"
- Next in thread: NIL: "RE: Can anybody show me how to open up a DAO connection to an Access d"
- Messages sorted by: [ date ] [ thread ]
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 >> >> >>
- Next message: rmsterling: "VB6-ADO-COM-ODBC-INFORMIX : Problem running query. SQL State 37000"
- Previous message: Brendan Reynolds: "Re: Error - Could not find installable ISAM"
- In reply to: Cliff Sutton: "Re: Can anybody show me how to open up a DAO connection to an Acce"
- Next in thread: NIL: "RE: Can anybody show me how to open up a DAO connection to an Access d"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|