Solved

ADO database searching

Posted on 2001-06-10
3
160 Views
Last Modified: 2013-11-13
I am using MS ADO 2.6 and I want to know how do I search a column for a certain entry.  I have a table called UserLog with columns called: Name, Date, Time.  The Name column has an index called PrimaryKey to prevent multiple entries.  How do I search the Name column for an entry called John Doe and will find it fast(I have a lot of entries in the database)?

This is my code to connect to the database:

Private Sub Command1_Click
Dim ILConnect As New ADODB.Connection
Dim ILRecordset As New ADODB.Recordset
ILConnect.Open "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=C:\windows\desktop\dfd.mdb"
ILRecordset.LockType = adLockPessimistic
ILRecordset.Open "UserLog", ILConnect, , , adCmdTable
End Sub
0
Comment
Question by:vpl4
3 Comments
 
LVL 6

Accepted Solution

by:
JonFish85 earned 50 total points
ID: 6174797
ILRecordset.Execute "SELECT * FROM TableName WHERE name='John Doe'"
ILRecordset.Refresh
Try that
0
 

Expert Comment

by:qazafiq
ID: 6175975
First of all if your planning to use ACCESS database only then there is nothing better than DAO.

Anyway thats just a thought, but do you really want to be going to the database everytime you make a search?

I dont think that would be a wise thing to do. Why dont we open a recordset containg all the data of the table, yes it would take long the first time it opens but after that all we need to do is filter our recordset. This would be alot faster.
0
 

Author Comment

by:vpl4
ID: 6179749
I think I submitted the question twice but got two different answers.  They both work and they give me two options to choose from.  Thanks for your assistance.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
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 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…

708 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

17 Experts available now in Live!

Get 1:1 Help Now