Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I search a database through VB using ADO?

Status
Not open for further replies.

BetoVelasco

Programmer
Sep 25, 2002
10
US
Hi
I'm wondering how to search a DataBase using a program in Visual Basic, for example I want to search all tha names begining with A so I enter the letter A in the textbox and it displays the info that begins with A.
Thanx
 
There's more to it than this, but this will get you started

1. Open a new project.

2. On the form add a MSHFlexgrid, an ADODC control, a command button and a textbox

3. In properties window, select ADODC1 and set connection string to :
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program Files\Microsoft Visual Studio\VB98\BIBLIO.MDB;Persist Security Info=False

You may need to change this to reflect your actual path to the biblio.mdb

4. set ADODC1 recordsource to AdCmdText, with this string :
SELECT Authors.Author FROM Authors

5. set the flexgrid datasource to ADODC1

6. Paste this into the form code window:

Private Sub Command1_Click()
Dim mySQl As String
mySQl = "SELECT Authors.Author "
mySQl = mySQl & "FROM Authors WHERE Author Like '"_
& Text1.Text & "%'"
Adodc1.RecordSource = mySQl
Adodc1.Refresh
End Sub

Run the app, type your letters to select into the textbox and hit command1
Let me know if this helps
________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'There are 10 kinds of people in the world: those who understand binary, and those who don't.'
 
Thank you very much it is working!
its alive!!!!! haha

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top