Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > VB.NET 2002/2003 Basics
|
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 1st, 2005, 03:46 AM
Authorized User
 
Join Date: Sep 2004
Posts: 57
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Brettvan1
Default Using ado.net and data binding

Hi all,

I am really battling with an application and would be most grateful if anyone could give me some pointers.

I need to create a program to view orders placed by customers.

They have asked for 2 screens.The first will allow a selection of a customer ID from a drop down list box.The screen will then display all the selected customer details(first name, last name, city ,state zip, code) in read only textboxes.A data grid will also be on this screen to show all orders place by this customer.None of this data will be editable.This application is purely for viewing purposes.

I do hope someone can shed some light on this for me and thank you in advance for taking some time out to give me a hand.

Kind regards
George


 
Old August 1st, 2005, 09:14 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default

What exactly do you want help with? It sounds like you have mapped out what you need to do...
 
Old August 2nd, 2005, 07:42 AM
Authorized User
 
Join Date: Sep 2004
Posts: 57
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Brettvan1
Default

I am wanting to bind six names from a dataset to my dropdown combobox.

Regards
Brett

 
Old August 2nd, 2005, 08:28 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Is that the total contents of your dataset, or do you have more names than that?
 
Old August 3rd, 2005, 09:53 AM
Authorized User
 
Join Date: Sep 2004
Posts: 57
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Brettvan1
Default

Sorry for being so vague, just really confused. what I need to do first of all is to bind my dropdown combobox to my database which has first name, last name, city, state and zip code.
B

 
Old August 3rd, 2005, 12:26 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default

If you already have your dataset filled, then you can simply set 2 properties of the combobox:

'note: don't include the square brackets...
ComboBox1.DataSource = ds.Tables("[TableName]") 'this is the name of the table in the dataset
ComboBox1.DisplayMember = "[ColumnName]" 'this is the name of the column to bind to

---------------------------------------------

However, I have had various problems when binding comboboxes so I choose not to do it. Instead, I loop through the dataset and add items manually to the combobox. Slightly more work but it allows much more flexibility and I don't have the same issues.

J
 
Old August 4th, 2005, 04:01 AM
Authorized User
 
Join Date: Sep 2004
Posts: 57
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Brettvan1
Default

Thanks so much for your help.....

What I need to do now i think is to use the currency manager to display the relevent deatils in my 5 textboxes.

When i click on the combobox drop down list and select customerID1,the first name, last name, city, state and zip code need to appear in my 5 readonly text boxes...If I select customerID 4 then those particular details need to apperar...etc...etc

Any further help would be very much appreciated and thanks again for taking time out to lend me a hand.

Regards
B

 
Old August 4th, 2005, 08:59 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default

I haven't used the currency manager...

What you can do is use the same dataset, but instead of populating it with only the single field, populate it with all of the fields that you require. Then when the selected index of the first textbox changes you can set the text property to the fields you want. The reason you can do this is that your dataset is indexed at 0 and so is your combobox.

So, if the user selects an item in the combobox it would look something like this:

Textbox1.Text = ds.Tables("TableName").Rows(ComboBox1.SelectedInde x).Item(1)
'assuming item 1 is the 2nd field in your row - 1 would likely be the field in the combobox

Textbox2.Text = ds.Tables("TableName").Rows(ComboBox1.SelectedInde x).Item(2)
Textbox3.Text = ds.Tables("TableName").Rows(ComboBox1.SelectedInde x).Item(3)
Textbox4.Text = ds.Tables("TableName").Rows(ComboBox1.SelectedInde x).Item(4)
Textbox5.Text = ds.Tables("TableName").Rows(ComboBox1.SelectedInde x).Item(5)

etc...

I have substituted generic names for your objects because I don't know what they are - change them accordingly.

And, the final thing is to put this in the SelectedIndexChanged event of the combobox (ComboBox1).

J
 
Old August 4th, 2005, 10:49 AM
Authorized User
 
Join Date: Sep 2004
Posts: 57
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Brettvan1
Default

What can I say....You are a genius !! Thank you so very much for all of your help.
B

 
Old August 4th, 2005, 01:19 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Your welcome!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Get data from Excel file using ADO.NET lam_lvl ADO.NET 7 February 27th, 2014 05:19 AM
confusing in ADO.NET Entity Data Model,Linq to sql angelboy ADO.NET 5 November 21st, 2008 05:01 PM
Data management with ADO.NET GriffithsJ BOOK: Professional ASP.NET 2.0 and Special Edition; ISBN: 978-0-7645-7610-2; ISBN: 978-0-470-04178-9 1 February 13th, 2006 12:57 PM
VB6 ADO Dynamic Data Binding Question pad Pro VB Databases 1 January 28th, 2005 10:43 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.