Setting up Query Form

  • Thread starter Thread starter Brent Burkart
  • Start date Start date
B

Brent Burkart

I am new to ado.net and I would like to set up a page which allows the user
to query information. In other words I want them to be able to bring back
information based on the dates they select. Once that information has
returned, I would like to give them further abilility to filter and
eliminate data.

The only way I knew of doing this was to send an SQL query to the database
everytime they select a new piece of information. It sounds as if their
might be a way around this in ADO.NET, but I have not figured it out.
Since all the data is returned in my Dataset, it seems as if I don't need to
reconnect to the database to requery based on another variable.

Is this possible? Any idea is appreciated.

Brent
 
Yes, it's possible, and simple to implement.

Fire the first query and fill your dataset based on the
date ranges. Right after that, create a module level
DataView like (Assuming the DataView has already been
declared.

dv = myDataSet.Tables(0).DefaultView;

'you can create seperate views for each table if you want.

So let's say you have a field called EmployeeID and you
have a commbo box for instance that lets the user select
the employeee...in the combo's selectedIndexChanged event
all you need to do is dv.RowFilter = "EmployeeID = '"
+cbo.SelectedItem + "'";

You can do the same with any other control although the
event could be different.

Also, depending on how many updates are submitted to the
DB, you may want to periodically refresh your query and
repeat the above steps so data doesn't get stale....that's
dependent on the app though.'

Also, there is a RowStateFilter which allows you to filter
records if they've been added, modified etc.

Let me know if you have any problems.

Cheers,

Bill


W.G. Ryan
(e-mail address removed)
www.knowdotnet.com
 
Back
Top