By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,851 Members | 1,022 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,851 IT Pros & Developers. It's quick & easy.

select query changing bound controls data

P: n/a
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.

Feb 28 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a

phonl wrote:
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.

--
Larry Lard
Replies to group please

Feb 28 '06 #2

P: n/a
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?
"Larry Lard" <la*******@hotmail.com> wrote in message
news:11*********************@u72g2000cwu.googlegro ups.com...

phonl wrote:
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.

--
Larry Lard
Replies to group please

Feb 28 '06 #3

P: n/a
Hi Phonl,

If you need to define the Select in the runtime, we need to create the Data
Access code ourself.
Here is a link about how to do DataBinding at runtime, you may have a try.
See Binding to Controls Programmatically
http://www.developer.com/net/vb/article.php/3558771

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Mar 1 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.