Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default problem in seek value in recordset with index.

Hi,
now I try to use index in recordset to improve my program speed,
I create a table name: values_Clplus_YTD
have three column: entity, account, value. and I create primarykey index for
column entity and account.

now I have code as following,
SQL = "select * from values_Clplus_YTD"
Access_ADO_Connect ' defined function
Set acceRs = New ADODB.Recordset
acceRs.Open SQL, acceConn, adOpenKeyset, adLockReadOnly, adCmdTableDirect
If Not acceRs.EOF Then
If acceRs.Supports(adIndex) And acceRs.Supports(adSeek) Then
acceRs.Index = "PrimaryKey"
acceRs.Seek dataArry, adSeekAfterEQ
MsgBox acceRs.fields("entity") & acceRs.fields("account")
End If
End If

acceRs.Close
Set acceRs = Nothing
Access_ADO_Disconnect ' defined function

acceRs.Supports(adIndex) and acceRs.Supports(adseek) always say false
whenever I set open recordset with adOpenKeyset. so I can't use seek function.

anyone can help me out, thanks in advance
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default problem in seek value in recordset with index.

Hi Miao,

acceRs.Supports(adIndex) and acceRs.Supports(adseek) always say false
whenever I set open recordset with adOpenKeyset. so I can't use seek function.

anyone can help me out, thanks in advance


IIRC, Seek is only available with a direct table connection, which you've
correctly passed in the Open method, but I think you should just be passing the
name of the table in the SQL string, not a query:

acceRs.Open "values_Clplus_YTD", acceConn, adOpenKeyset, adLockReadOnly,
adCmdTableDirect

Regards

Stephen Bullen
Microsoft MVP - Excel
www.BMSLtd.ie


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 593
Default problem in seek value in recordset with index.

"miao jie" wrote ...
Hi,
now I try to use index in recordset to improve my program speed,
I create a table name: values_Clplus_YTD
have three column: entity, account, value. and I create primarykey index for
column entity and account.

now I have code as following,
SQL = "select * from values_Clplus_YTD"
Access_ADO_Connect ' defined function
Set acceRs = New ADODB.Recordset
acceRs.Open SQL, acceConn, adOpenKeyset, adLockReadOnly, adCmdTableDirect
If Not acceRs.EOF Then
If acceRs.Supports(adIndex) And acceRs.Supports(adSeek) Then
acceRs.Index = "PrimaryKey"
acceRs.Seek dataArry, adSeekAfterEQ
MsgBox acceRs.fields("entity") & acceRs.fields("account")
End If
End If

acceRs.Close
Set acceRs = Nothing
Access_ADO_Disconnect ' defined function

acceRs.Supports(adIndex) and acceRs.Supports(adseek) always say false
whenever I set open recordset with adOpenKeyset. so I can't use seek function.

anyone can help me out, thanks in advance


You need a client side cursor plus a data engine *and* data provider
that supports Seek and Index. I can't see anything wrong with your
code but perhaps your experience suggests a flawed approach i.e. such
operations should be undertaken on the server side e.g. using a stored
procedure. Otherwise, you may find you have to use another recordset
method such as Find or Filter. If you need an index for performance,
take a look at the Optimize dynamic property:

http://msdn.microsoft.com/library/de...ropertyrds.asp

Jamie.

--
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with Goal Seek [email protected] Excel Worksheet Functions 2 August 29th 06 04:10 PM
goal seek problem mpreddy Excel Programming 1 August 18th 04 03:54 PM
ADODB Recordset problem Stefen Percoco Excel Programming 2 July 26th 04 06:31 PM
Recordset Problem - object is closed DBAL Excel Programming 0 June 4th 04 11:55 PM
Conceptual Problem with DAO/ADO Recordset Eddy[_3_] Excel Programming 0 September 8th 03 07:43 AM


All times are GMT +1. The time now is 03:48 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"