select query changing bound controls data

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.
 
L

Larry Lard

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.
 
P

phonl

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top