Solved

Changing the querry of ADO recordset

Posted on 2000-04-01
6
314 Views
Last Modified: 2013-11-23
Hi,
I have a small VB application with an access database as backend.  I amd using ADO connection.  It is working fine.  Now my requirement is very simple.  I have a text box in which if I type some thing, the records beginning with that should be displayed.  Initially I was using DAO and I was able to do this.  Now I'm trying to use ADO.  I don't know how to do this using ADO.  Basically I want to change the contents of the recordset at runtime depending upon a different querry.  Please help me in this with the command/syntax.

Thanks in advance,
Benny
0
Comment
Question by:bennyv
6 Comments
 
LVL 6

Expert Comment

by:Marine
ID: 2675933
"Select * from TableName where FieldName like '" & Text1.Text & "*'"
0
 
LVL 3

Expert Comment

by:altena
ID: 2675982
One way to do this is to create a new Recordset object when you need to re-query. (The old one will be destroyed by VB).

Another way is to use a parameterized query. Use the ADO.Command object. (This may not work correctly with older versions of access, so be carefull.)

Good Luck

0
 

Accepted Solution

by:
anand_m earned 50 total points
ID: 2676183
Try to display this using ADO recordset Find Method. Whenever you type a word,try to match for that word in the Recordset
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 14

Expert Comment

by:wsh2
ID: 2676237
Benny:
Post your old code.. a picture is worth a thousand words.. <smile>.

altena:
you write: "One way to do this.. Another way.." How is this a definitive answer? Shame on you for locking this question down with an answer rather than allowing other comment.

The gyst of what the questioner is saying is "I don't know HOW to do this using ADO".. To that means.. your answer hardly suffices. By the way.. your parameterized ADO Command Object solution implies a Stored database procedure.. and I saw no mention of that anywhere in the question. To be honest, the questioner has not provided enough information.

Please remove your answer, so that Benny can benefit from other's comments.. and perhaps, benefit further by additional "comments" of your own making.. <smile>.
0
 

Author Comment

by:bennyv
ID: 2677416
I would like to accept the answer of anand m rather than altena's because altena didn't give me the code to use.  Anand's method was easy to use and I got the syntax from MSDN.  I tried Altena's answer also (by closing the current recordset and reopening it with the new query); but it did not work.  It is not displaying anything.  The absolute position is coming as -1.  But anand's method is working perfectly.  This is the code I used. :

Private Sub txtSearch_Change()
sqls = "NAMES LIKE " & "'" & txtSearch.Text & "*'"
adoPrimaryRS.MoveFirst
If txtSearch.Text <> "" Then
adoPrimaryRS.Find sqls
End If
End Sub

I would like to accept anand's answer.

Thanks altena.
Thanks to everybody for answering my question.

Benny
0
 

Author Comment

by:bennyv
ID: 2677422
One reason why I felt anand's answer is better is that, I feel it will be more efficient.  Because you are not reopening the record set.

Thanks anand
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now