473,320 Members | 2,110 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

select query changing bound controls data

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
3 1937

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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
by: James Fortune | last post by:
I have a lot of respect for David Fenton and Allen Browne, but I don't understand why people who know how to write code to completely replace a front end do not write something that will automate...
32
by: deko | last post by:
I have a popup form with a textbox that is bound to a memo field. I've been warned about memo fields so I'm wondering if I should use this code. Is there any risk with changing the form's...
1
by: dm1608 | last post by:
Hi all -- I'm rapidly learning ASP.NET 2.0 (never really did much .NET before... mainly an ASP and PHP guy until now) and seem to be having some technical challenges that I'm hoping someone can...
9
by: Vmusic | last post by:
Hi, I'm using MS Access 2002. I have a form with a combo box built from a query that returns one column, and that one column is the bound column. How do you use VBA to programmatically change...
6
by: gerbski | last post by:
Hi all, I am relatively new to ADO, but up to now I got things working the way I wanted. But now I've run into somethng really annoying. I am working in MS Access. I am using an Access...
3
by: Phillip Vong | last post by:
I'm new and trying to learn. This is in VB.NET 2. I have a simple page with one Textbox1, one Label1 and one Button1. The on_click Button one goes and get's a simple data from the SQL db with...
5
by: njb35 | last post by:
Hi all I'm beginning my foray from VBA into VB 2005 Express, and enjoying some of the efficiencies it provides! I'm stuck with some dataset handling however that I _think_ can be automated but...
0
jenka1980
by: jenka1980 | last post by:
What is the best way to correspond SkinId in GridView to the data which bound to it ? I have dataset which I bound to a GridView. Dataset contains a table where part of rows are title rows....
5
by: OldBirdman | last post by:
I am attempting to assign a .RowSource to a ListBox using an SQL statement. I want to build the SQL statement "On-the-Fly", based on values in several controls on the form. I would like to restrict...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.