Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > Database and Reporting > how do you search a database


Reply
 
Thread Tools Display Modes
  #1  
Old 05-09-2002, 03:26 PM
mopntu
Guest
 
Posts: n/a
Question how do you search a database


can you give a text box the ability to search a database, and if so how
Reply With Quote
  #2  
Old 05-09-2002, 03:33 PM
reboot's Avatar
reboot reboot is offline
Keeper of foo

Retired Moderator
* Guru *
 
Join Date: Nov 2001
Location: Graceland
Posts: 15,612
Default

I tried to think of some witty reply to this, but failed. If I have to answer your question strickly, the only answer I can give you is No. A textbox cannot search a database. Now... you could write code to search a database for the value placed in a textbox. Is this really what you're asking?
Reply With Quote
  #3  
Old 05-13-2002, 08:03 AM
mopntu
Guest
 
Posts: n/a
Default

yes thats what i need. thank you
Reply With Quote
  #4  
Old 05-13-2002, 08:45 AM
gallicus gallicus is offline
Junior Contributor
 
Join Date: Dec 2001
Location: at work... probably :-(
Posts: 366
Default

Please supply more information like the data base you are trying to query. This question is very broad, it covers a lot of what many programmers spend their careers doing! There is a lot of coding to be done for solve your problem. Try to break the problem down and into smaller chunks as ask these more specific questions. It sounds like this is a new area for you. It may well be worth investing time and money in a book. There are plenty of books recommmended in this forum.

Good Luck
__________________
(A)bort, (R)etry, (G)et a beer?
Reply With Quote
  #5  
Old 05-13-2002, 10:12 AM
Rezner's Avatar
Rezner Rezner is offline
C# Lover

* Expert *
 
Join Date: Jan 2002
Location: 00-80-C8-C3-2E-52
Posts: 1,899
Default

if you had a textbox called "txtSearchLastName" then you could use the value in it to search the database with something like this (using ADO):
Code:
RS.Open "SELECT * FROM [tblPeople] WHERE [LastName]='" & txtSearchLastName.Text & "'", adoConString
This would populate the recordset with people from the table whose last name is exactly the value in the textbox.
__________________
"Man is still the best computer we can put aboard a spacecraft...and the only one that can be mass produced with unskilled labor." - Wernher von Braun
Reply With Quote
  #6  
Old 05-13-2002, 01:52 PM
chris00's Avatar
chris00 chris00 is offline
 
Join Date: Mar 2002
Location: Ohio, USA
Posts: 1,552
Unhappy Same thing

I am trying to do the same thing. Search my Database and then place the results in an MSHFlexGrid named msh.
How would the best way to do this.

Thanks in advance


Chris
__________________
Chris
Reply With Quote
  #7  
Old 05-13-2002, 02:07 PM
Cogen's Avatar
Cogen Cogen is offline
Contributor
 
Join Date: Apr 2002
Location: Ontario, Canada
Posts: 673
Default

Maybe it's better to use sql for your purposes, but I thought I'd mention that if you already have recordsets in your application, you can also take a look at the methods Sort, Filter, and Search.

An example of the search would be ...

rsStudents.Find "Last_Name = '" & txtSearch.text & "'"

just an idea.
Reply With Quote
  #8  
Old 05-13-2002, 02:08 PM
Cogen's Avatar
Cogen Cogen is offline
Contributor
 
Join Date: Apr 2002
Location: Ontario, Canada
Posts: 673
Default

sorry, I didn't mean Sort, Filter, and Search.

I meant Sort, Filter, and Find.
Reply With Quote
  #9  
Old 05-13-2002, 02:18 PM
chris00's Avatar
chris00 chris00 is offline
 
Join Date: Mar 2002
Location: Ohio, USA
Posts: 1,552
Post

Cogen , Could you explain how I could list all record with "Pizza" (just an example) in the Description Colume, Which one of the thing you listed would I use. Then list it in the MSHFlexGrid (msh)

Sorry, I'm new to using a Database

Chris
__________________
Chris
Reply With Quote
  #10  
Old 05-13-2002, 02:35 PM
Cogen's Avatar
Cogen Cogen is offline
Contributor
 
Join Date: Apr 2002
Location: Ontario, Canada
Posts: 673
Default

honestly, I'm not that familiar with the MSHFlexGrid, so I can't really help you there, but as far as returning all records with Pizza in the description column, you would use .Filter. The main thing to remember is that those methods do not take the place of your SQL query, but they can narrow an already existing query into your search information.
For example, you would still need a recordset that is fully populated (probably by sql).
Maybe using SELECT * FROM table_name. (that's pretty broad though).
Then, with the recordset that contains the returned data, you can narrow the recordset down by using the filter method.
rsRecordSet.Filter "Description = 'Pizza'"

Now you can use the rsRecordSet as you normally would, however only the records with Pizza in the Description will be available.

Then, when you are done displaying the information, you can reset the recordset back to it's original state by using ...
reRecordSet.Filter = adFilterNone

I hope that helps ...
Reply With Quote
  #11  
Old 05-13-2002, 03:31 PM
matticus_99 matticus_99 is offline
Junior Contributor
 
Join Date: Mar 2002
Posts: 270
Default

Hi Chrisoo,
After you query the database you can use this line to populate the flex grid.

Set myGoodGrid.Recordset = myGoodRecordset





Edit:

Thats cool, I never took into account some peoples background may have been white.


Last edited by dcl3500; 05-13-2002 at 03:55 PM.
Reply With Quote
  #12  
Old 05-13-2002, 03:40 PM
dcl3500's Avatar
dcl3500 dcl3500 is offline
Mostly Harmless?

Retired Moderator
* Expert *
 
Join Date: Jun 2001
Location: Western Illinois, USA
Posts: 2,398
Default

Sorry Matticus_99 for editing that post, but pink was just too darn hard to see.
__________________
Don

"So long and thanks for all the fish.'" - Douglas Adams.
Reply With Quote
  #13  
Old 05-13-2002, 03:41 PM
mopntu
Guest
 
Posts: n/a
Default

i am trying to make a serchable japanese to english/ english to japanese dictionary with 2 textboxes (1 for search and 1 for translation) and a search button. i wanted the database to store information like this (nihongo - japanese)
Reply With Quote
  #14  
Old 05-13-2002, 03:58 PM
chris00's Avatar
chris00 chris00 is offline
 
Join Date: Mar 2002
Location: Ohio, USA
Posts: 1,552
Post

I did what all of your posts said. But is there a way I can get partial maches such as "box" would find Lunchbox.


Chris
__________________
Chris
Reply With Quote
  #15  
Old 05-13-2002, 04:01 PM
reboot's Avatar
reboot reboot is offline
Keeper of foo

Retired Moderator
* Guru *
 
Join Date: Nov 2001
Location: Graceland
Posts: 15,612
Default

"Like %box"
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->