Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 23rd, 2004, 06:06 AM
anca anca is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 30 anca User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Angry How to use ADO & Index

I want to use SEEK method to search in my table. I have an index and I know that SEEK will work faster than FIND. But I don't know why I can't set the index. The recordset defined in my program doesn't support INDEX property and I don't know what kind of recordset to use for this.

This is what I have now:

Set rsStoc = New ADODB.Recordset
With rsStoc
.CursorLocation = adUseClient
.CursorType = adCmdTable
.LockType = adLockBatchOptimistic
End With

I tried to open the recorset in 2 ways:
rsStoc.Open "Stoc", myConnection
or
rsStoc.Open "SELECT * FROM stoc", myConnection

but in both cases I've got an error when I did:

rsStoc.Index = "ID"

Is anybody here to tell me how to open this table?
__________________
Anca

Reply With Quote
  #2  
Old January 23rd, 2004, 09:14 AM
Fisherman's Avatar
Fisherman Fisherman is offline
Inherits Programmer.Slacker
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Aug 2003
Location: Between my Id and your Ego
Posts: 2,193 Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 13 h 55 m 17 sec
Reputation Power: 142
Send a message via ICQ to Fisherman Send a message via AIM to Fisherman
a question for you, Anca. Did you put an index in the table as well. If not, then assigning an index in the recordset will cause a failure
__________________
Fisherman

"Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius -- and a lot of courage -- to move in the opposite direction." - A.Einstein

Reply With Quote
  #3  
Old January 23rd, 2004, 02:52 PM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 13th Plane (11000 - 11499 posts)
 
Join Date: Jun 2003
Posts: 11,141 Doug G User rank is Lieutenant General (80000 - 90000 Reputation Level)Doug G User rank is Lieutenant General (80000 - 90000 Reputation Level)Doug G User rank is Lieutenant General (80000 - 90000 Reputation Level)Doug G User rank is Lieutenant General (80000 - 90000 Reputation Level)Doug G User rank is Lieutenant General (80000 - 90000 Reputation Level)Doug G User rank is Lieutenant General (80000 - 90000 Reputation Level)Doug G User rank is Lieutenant General (80000 - 90000 Reputation Level)Doug G User rank is Lieutenant General (80000 - 90000 Reputation Level)Doug G User rank is Lieutenant General (80000 - 90000 Reputation Level)Doug G User rank is Lieutenant General (80000 - 90000 Reputation Level)Doug G User rank is Lieutenant General (80000 - 90000 Reputation Level)Doug G User rank is Lieutenant General (80000 - 90000 Reputation Level)Doug G User rank is Lieutenant General (80000 - 90000 Reputation Level)Doug G User rank is Lieutenant General (80000 - 90000 Reputation Level)Doug G User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 2 Days 17 h 13 m 7 sec
Reputation Power: 857

Reply With Quote
  #4  
Old January 26th, 2004, 04:49 AM
anca anca is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 30 anca User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Yes, I have an index on this table. I created it when I created the table. I guess it's something with the way I am opening the table.

That link, from Doug, doesn't say much about the cause of the error.

Maybe is somebody there who can send me a small example - a working one?

Reply With Quote
  #5  
Old January 26th, 2004, 04:53 AM
anca anca is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 30 anca User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Is that any chance that "Microsoft.Jet.OLEDB.4.0" as provider doesn't support indexes? In this case which should be the provider for my MDB file?

Reply With Quote
  #6  
Old January 26th, 2004, 08:52 AM
Fisherman's Avatar
Fisherman Fisherman is offline
Inherits Programmer.Slacker
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Aug 2003
Location: Between my Id and your Ego
Posts: 2,193 Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 13 h 55 m 17 sec
Reputation Power: 142
Send a message via ICQ to Fisherman Send a message via AIM to Fisherman
I don't believe that the JET provider would have any conflicts there. Can you post the code where you are opening the table?

Reply With Quote
  #7  
Old January 28th, 2004, 04:51 AM
anca anca is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 30 anca User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
The code is on the first message of this thread. I found something on Doug's link - there is a good example - but I still don't understand why mine isn't work. I need to have write access to my table and I would like to keep that "batch" mode because looks to be very useful sometimes.

Does anybody know a link where I can find details about all parameters and related constants from OPEN method of ADODB.recordset? I want to understand them, not only find something that works.

Reply With Quote
  #8  
Old January 28th, 2004, 08:59 AM
Fisherman's Avatar
Fisherman Fisherman is offline
Inherits Programmer.Slacker
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Aug 2003
Location: Between my Id and your Ego
Posts: 2,193 Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 13 h 55 m 17 sec
Reputation Power: 142
Send a message via ICQ to Fisherman Send a message via AIM to Fisherman
you can use an if statement to check for support of the index property like so (I got this off of DevGuru)
Code:
If objRecordset.Supports(adIndex) Then
   objRecordset.Index = "AddressIndex"
End If

Here's a link to the information you asked for. Try using a server-side cursor instead of a client side one. I don't know if that will have any bearing or not, but I'm just curious as to the outcome.

Reply With Quote
  #9  
Old January 29th, 2004, 08:28 AM
anca anca is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 30 anca User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
I know that and I tested it.... it doesn't support index.... the big question is "why"??

From your experience - what is the better way to open a table if i want to have full access to change it?
- I have network and other users may want to do the same maybe
- I want to be able to edit record, AddNew or Delete
- I would like to be able to "cancel" some things like AddNew or edit

Thanks

Reply With Quote
  #10  
Old January 29th, 2004, 08:56 AM
Fisherman's Avatar
Fisherman Fisherman is offline
Inherits Programmer.Slacker
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Aug 2003
Location: Between my Id and your Ego
Posts: 2,193 Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 13 h 55 m 17 sec
Reputation Power: 142
Send a message via ICQ to Fisherman Send a message via AIM to Fisherman
if you are wanting to open the table for editing, and other users may be editing the same table at the same time, you will most likely want to use either adLockOptimistic or adLockBatchOptimistic. Usually, people go for the first one, because most programmers don't know when to use batch-type processing. Personally, as a generality and not knowing the ins and outs of your particular situation, I would say that a CursorType of adOpenDynamic, a CursorLocation of adUseServer, and a LockType of adLockOptimistic might work best. That's not based on an informed decision, though. One thing I would tell you, though - unless you have reason to open an entire table at a time, I would recommend you select specific records for processing using Select SQL statements based on information gained somewhere else in your program.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > How to use ADO & Index


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT