Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Changing the querry of ADO recordset

Posted on 2000-04-01
6
Medium Priority
?
324 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 150 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

916 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