How do I get data from Database Table selection into other TextBoxes?

4

4

I am having some trouble w/ a school project database that I am doing. The
database is used for a ski rental shop. In the rental table I have various
customers w/ rentals on different days. I have a combobox that selects the
customer number from my customer table. What I would like it to do is
propigate the data into text boxes, then have another combo box where I can
select the date of the rental so that I can display the rental information
for the invoice. I am not sure how to get this to work properly as I am
still on a steep curve w/ database interfacing. Any help would be great!
Thanks in advance!

Brad B.
brad_britton atdisdsa hotmail.com
 
G

Guest

One thing you might want to try is DataBinding. You should be able bind your SQL data table to the ComboBox. I believe you can either do this directly to the sql dataset you pulled or into a datatable that is derived from your sql dataset. In the combo box you can set the display colum and and a value to key of. Then in the selection change event you access the data table and populate each field on the screen... ie:

txtName.Text = mydatatable.rows[box.selectedindex]["name"].Tostring();

Where "name" is the column name. You could also look at binding to data grids. A good place to read on this would be under the DataTable/DataRows/DataBinding areas. There are many different ways to do this. I am sure some others will chime in as well. Think of your data table as if it was a sql record set.
 

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