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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Querying a dataset

Status
Not open for further replies.

drimades

IS-IT--Management
Nov 8, 2004
221
MK
Visual Basic 2008

I have a dataset called qbf2kDataSet. Currently it is just a table of the database. Using an SQL query how can I query the existing dataset qbf2kDataSet and return the resulting records to a new dataset qbf2kNew?
 
drimades,

You may want to look up dataset filtering. you can add an sql where clause to the dataset and trim the amount of data returned.

-Sometimes the answer to your question is the hack that works
 
Following the guide of Visual Basic they say:

To create a parameterized query and controls to enter the parameters
Select the DataGridView control, and then choose Add Query on the Data menu.

Type FillByCity in the New query name area on the Search Criteria Builder Dialog Box.

Add WHERE City = @City to the query in the Query Text area.

The query should be similar to the following:

SELECT CustomerID, CompanyName, ContactName, ContactTitle, Address, City, Region, PostalCode, Country, Phone, Fax

FROM Customers

WHERE City = @City

Note:
Access and OleDb data sources use the question mark '?' to denote parameters, so the WHERE clause would look like this: WHERE City = ?.


Click OK to close the Search Criteria Builder dialog box.

A FillByCityToolStrip is added to the form.


This if I have only a word in the textbox of City (for example). What if I have 2 or more words (and so more conditions) written in the textbox called City?

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top