Board index » delphi » Seek method for ADO dataset doesn't work for me

Seek method for ADO dataset doesn't work for me

Can anyone confirm that the ADODataset.Seek method still works under the
latest Borland and Microsoft updates?  It does not work for me now, and I
cannot think of anything else I've done that might have made it stop working
when it once did.  In particular, if I try to run the SeekDemo from the book
Advanced Delphi Developers Guide for ADO, I get only the error message
"ADODataSet1. Cannot perform this operation on a closed dataset."
Within the IDE, when I try to change the dataset's Active property to True
from False, I get the message "Object or provider is not capable of
performing requested operation."

Does anyone have any idea what may be causing these problems and how to
resolve them?  Thanks for your attention and assistance.

 

Re:Seek method for ADO dataset doesn't work for me


Quote
>Does anyone have any idea what may be causing these problems and how to
>resolve them?

You need to be using Access
set CursorLocation = clUseServer
Command type TableDirect to True
and IndexName specified
for Seek to work.

--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

Re:Seek method for ADO dataset doesn't work for me


I know, and all of these requirements have been met, but the symptoms I
describe persist.

(Actually, Command Type shows in the drop-down box as cmdTableDirect,but I
understand that that is how one sets it true, as required.  Also, the
IndexName is set to City, as always for the demo, and that is an index that
allows duplicates, but I cannot see that that should matter.  I'm pretty
sure that the demo used to work, and I can see in the documentation, as can
you, that it is supposed to work under the limited circumstances you spell
out, but it doesn't.)

I take it you can actually make it work?  Are all of your
updates current?  I'm guessing  that one of them broke things for me.

Thanks for the reply.  I'd sure like to get to the bottom of this.

Bob

Brian Bushay TeamB <BBus...@Nmpls.com> wrote in message
news:s8du9t40t8bbj6ajq21ev9mvd08i58ne40@4ax.com...

Quote

> >Does anyone have any idea what may be causing these problems and how to
> >resolve them?

> You need to be using Access
> set CursorLocation = clUseServer
> Command type TableDirect to True
> and IndexName specified
> for Seek to work.

> --
> Brian Bushay (TeamB)
> Bbus...@NMPLS.com

Re:Seek method for ADO dataset doesn't work for me


Hi Bob,

Quote
> I know, and all of these requirements have been met, but the symptoms I
> describe persist.

Do you use Access 2000? I think that Seek does not work with Access 97.

Thrse

Re:Seek method for ADO dataset doesn't work for me


Hi (sorry my  Cyrillic fonts have mangled your name)

Yes, I'm using Access 2000, and I think you're right that it won't work with
Access 97.  But it is supposed to work with Access 2000 and doesn't.  For
what its worth, here is the information on the provider I'm using:

Microsoft Jet 4.0 OLE DB Provider (Microsoft.Jet.OLEDB.4.0)
CLSID   : {dee35070-506b-11cf-b1aa-00aa00b8de95}
Path    : C:\WINNT\System32\msjetoledb40.dll
Version : 4.00.2927.2

If you can make it work, perhaps you can check to see if your version is
different from mine.  Last week I applied the most recent updates from
Microsoft and Borland and that's the only reason I can think of that things
are now broken.

Thanks for the reply

Bob

Quote
Thrse Hanquet <therese.hanq...@skynet.be> wrote in message

news:3a9fc333$1_2@dnews...
Quote
> Hi Bob,

> > I know, and all of these requirements have been met, but the symptoms I
> > describe persist.

> Do you use Access 2000? I think that Seek does not work with Access 97.

> Thrse

Re:Seek method for ADO dataset doesn't work for me


Hi Bob,

Yes, I use version 4.00.2927.2, and it works for me.

I wonder if the problem is not with IndexName. As far as I remember (I
don't have an app to try it right now), you can set IndexName to something
other than blank ('') only if the dataset is already open (that would
explain the error message you get). Maybe try leaving it blank and setting
it after you have set ADODataSet1.Active to True.

Thrse

Re:Seek method for ADO dataset doesn't work for me


Hi again Therese,

The advice you gave (temporarily) got me around the problem of setting the
Active property to true.  By removing the Index property info I was able to
set the ADODataSet1.Active to true and see the data in my grid control.  I
then set the IndexName property to City and watched the data in the grid get
sorted correspondingly.  But when I compile or run the app, I get the
following message: "Project SeekDemo.exe raised exception class
EOleException with message 'Object or provider is not capable of performing
requested operation'."  When I check the IDE again, the Active property is
False again and I'm back to the state I described earlier.

Thanks for the help, but I'm still out of luck it seems.  Any other ideas of
things to try?

Bob

Quote
Thrse Hanquet <therese.hanq...@skynet.be> wrote in message

news:3a9fd7ce_2@dnews...
Quote
> Hi Bob,

> Yes, I use version 4.00.2927.2, and it works for me.

> I wonder if the problem is not with IndexName. As far as I remember (I
> don't have an app to try it right now), you can set IndexName to something
> other than blank ('') only if the dataset is already open (that would
> explain the error message you get). Maybe try leaving it blank and setting
> it after you have set ADODataSet1.Active to True.

> Thrse

Re:Seek method for ADO dataset doesn't work for me


Hi Robert,

I have had this happen to me. My guess is that when you compile and start
the adodataset is closed and then reopened, so it can be working fine at
design time and still bring up that error message when you try to run the
program. The only way I have found to overcome this is to make sure I clear
the indexname before running the program and then restore the indexname
after the adodataset has been opened.

Graham Plain
Prism Communications.

Quote

> The advice you gave (temporarily) got me around the problem of setting the
> Active property to true.  By removing the Index property info I was able
to
> set the ADODataSet1.Active to true and see the data in my grid control.  I
> then set the IndexName property to City and watched the data in the grid
get
> sorted correspondingly.  But when I compile or run the app, I get the
> following message: "Project SeekDemo.exe raised exception class
> EOleException with message 'Object or provider is not capable of
performing
> requested operation'."  When I check the IDE again, the Active property is
> False again and I'm back to the state I described earlier.

> Thanks for the help, but I'm still out of luck it seems.  Any other ideas
of
> things to try?

Re:Seek method for ADO dataset doesn't work for me


Hi Bob,

It's difficult knowing what you are doing without knowing what you have as
code in your app (for example, do you call Seek with a button?) and how
exactly you compile it.

If you compile your app with ADODataSet1.Active = True and IndexName =
'City', I guess it might not work because the compiled app tries to open
the dataset with IndexName set to something other than blank.

As I understand it, you should leave IndexName blank in the IDE, and set
IndexName to 'City' in your code once the dataset is opened. For example
you can set IndexName in the OnClick event of the button you use to call
Seek (if you do). Or you leave the dataset closed (and IndexName blank) in
the IDE , open it in code and then set IndexName.

Also, did you try using IndexFieldNames rather than IndexName? It might
behave differently.

Hope it will work this time... once again I did not try.

Thrse

Re:Seek method for ADO dataset doesn't work for me


Amazing!  Changing the properties at run time by linking them to the button
click event solved the problem.  How did you know to do that?  I didn't see
the least hint of that in any of the documentation or books I've pored over.
Certainly the sample code in the Fedorov/Elmanova book carries no suggestion
of it.  Btw, as soon as I supply City as the IndexName, City is also
automatically filled in as the IndexFieldName.

Thanks very much for your help.  I doubt I would ever have figured it out
without it.

Bob

Quote
Thrse Hanquet <therese.hanq...@skynet.be> wrote in message

news:3a9fe93e_2@dnews...
Quote
> Hi Bob,

> It's difficult knowing what you are doing without knowing what you have as
> code in your app (for example, do you call Seek with a button?) and how
> exactly you compile it.

> If you compile your app with ADODataSet1.Active = True and IndexName =
> 'City', I guess it might not work because the compiled app tries to open
> the dataset with IndexName set to something other than blank.

> As I understand it, you should leave IndexName blank in the IDE, and set
> IndexName to 'City' in your code once the dataset is opened. For example
> you can set IndexName in the OnClick event of the button you use to call
> Seek (if you do). Or you leave the dataset closed (and IndexName blank) in
> the IDE , open it in code and then set IndexName.

> Also, did you try using IndexFieldNames rather than IndexName? It might
> behave differently.

> Hope it will work this time... once again I did not try.

> Thrse

Re:Seek method for ADO dataset doesn't work for me


Hi Bob,

Quote
> Amazing!  Changing the properties at run time by linking them to the
button
> click event solved the problem.  How did you know to do that?

Just many "trials and errors" some time ago... it helps to guess ;)
Glad it worked, and thanks for the feedback.

Thrse

Other Threads