Thanks for the replies. cjard you mean I should use the get method rather than the fill method when I create my queries?
Get and Fill both approach the database to return (a subset of) rows from the table. The difference is that Fill fills an existing table, and Get gets you a new table. Typically, when working with bound data you would Fill whatever table the controls are bound to
What I meant by not downloading a million rows then client side filtering them was:
Write a Fill query that takes a parameter:
FillByUser(myDataTableToFill, "john smith")
Rather than download a million users, then filter locally:
Fill(myDataTableToFill)
myDataTableToFill.DefaultView.Filter = "[name] = 'john smith'"
Hopefully the reasons for this are fairly obvious
but here's a run down:
The latter doesnt use database indexes, generates massive amounts of network traffic and uses a dumb search strategy. In short, it's the slowest, worst way to do a search. DBs are for searching.
Also the video does not advice how to go when you want to use more than one field for filtering
Write your query like this:
SELECT * FROM table WHERE
stringColumn LIKE @stringParam AND
(numberColumn = @numberParam OR @numberParam IS NULL) AND
(dateColumn = @dateParam OR @dateParam = #01-JAN-1900#) AND
(dateColumn BETWEEN @lowerDate AND @upperDate)
To wildcard the string, pass "%" as a value
To wildcard the number, pass Nothing
To wildcard the date, pass New DateTime(1900, 1, 1)
Or if youre using date ranges pass very low and very high values
Naturally, if youre using a DB that cannot have numbers be NULL or whjatever, you have to be sensitive to the needs of the DB. Pass a number that will never occur, like -999999999, and check whether the parameter is equal to that too
If you can't see how it works, let me know, but basically each clause to be wildcarded must evaluate its OR to true