Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > VB.NET 2002/2003 Basics
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 1st, 2005, 03:46 AM
Authorized User
 
Join Date: Sep 2004
Location: , , .
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


Reply With Quote
  #2 (permalink)  
Old August 1st, 2005, 09:14 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
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...
Reply With Quote
  #3 (permalink)  
Old August 2nd, 2005, 07:42 AM
Authorized User
 
Join Date: Sep 2004
Location: , , .
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

Reply With Quote
  #4 (permalink)  
Old August 2nd, 2005, 08:28 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
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?
Reply With Quote
  #5 (permalink)  
Old August 3rd, 2005, 09:53 AM
Authorized User
 
Join Date: Sep 2004
Location: , , .
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

Reply With Quote
  #6 (permalink)  
Old August 3rd, 2005, 12:26 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
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
Reply With Quote
  #7 (permalink)  
Old August 4th, 2005, 04:01 AM
Authorized User
 
Join Date: Sep 2004
Location: , , .
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

Reply With Quote
  #8 (permalink)  
Old August 4th, 2005, 08:59 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
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
Reply With Quote
  #9 (permalink)  
Old August 4th, 2005, 10:49 AM
Authorized User
 
Join Date: Sep 2004
Location: , , .
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

Reply With Quote
  #10 (permalink)  
Old August 4th, 2005, 01:19 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Your welcome!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 02:11 AM.


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