select query changing bound controls data

  • Thread starter Thread starter phonl
  • Start date Start date
P

phonl

I am a vb6 ADO developer looking at vb.net 2005 and ADO2.net.

I used the vb.net 2005 data wizard to bind some controls to a database. Now
I want to run a select query and have the bound controls reflect the change
from the query. How would I do that?

The wizard created a TableAdapter, BindingSource, and DataSet. Somehow I
need to run feed them a select query to update the data.
 
phonl said:
I am a vb6 ADO developer looking at vb.net 2005 and ADO2.net.

I used the vb.net 2005 data wizard to bind some controls to a database. Now
I want to run a select query and have the bound controls reflect the change
from the query. How would I do that?

The wizard created a TableAdapter, BindingSource, and DataSet. Somehow I
need to run feed them a select query to update the data.

In the dataset designer, rightclick the tableadapter, choose Add |
Query... and follow through the wizard. When asked to supply the query
text, you can use parameters (eg in a access db, "select blah from
orders where id=?)". This will create a new method on the TableAdapter
called... well, called what you like, but I typically name mine
FillBy<parameter name>, eg FillByOrderDate. This method will take the
parameter as an argument. Then to run the query just do
MyTableAdapter.FillByWhatever(whatever) - this will run the query and
your bound controls will reflect the new resultset.
 
Yup, that works! Thank you.

Let me ask you to take it one step further...

Let say, I can't make a query in advance because I don't know what it is at
design time; so I put an unbound text box on the form for typing in a select
statement and I want to execute the select statement against the bound
controls. How would I do that?
 
Back
Top