importing data from excel to comboBox

Please support our VB.NET advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Aug 2007
Posts: 18
Reputation: apchidara is an unknown quantity at this point 
Solved Threads: 0
apchidara apchidara is offline Offline
Newbie Poster

importing data from excel to comboBox

 
0
  #1
Aug 28th, 2007
hi every one after connecting to an excel file I want to import the firts row into a combobox
in the connection function I added thhis
MyCommand = New System.Data.OleDb.OleDbDataAdapter("select * from[sheet1$]", MyConnection)
MyCommand.TableMappings.Add("Table", "Attendence")

DtSet = New System.Data.DataSet
MyCommand.Fill(DtSet)
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
ComboBox1.datasource= DtSet.Tables(0) i think this is error

and when I run my combo box will get filled with nSystem.Data.DataRowView

by the way I want only th first row to get imported in my cobo box how is the sql query

thanks in advance
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 26
Reputation: shikeb is an unknown quantity at this point 
Solved Threads: 0
shikeb's Avatar
shikeb shikeb is offline Offline
Light Poster

Re: importing data from excel to comboBox

 
0
  #2
Aug 28th, 2007
Hi,

Here is a link to Ken Getz's really good artile on manipulating Exel with
VB.NET. It includes the logic you need to extract things such as worksheets
which would allow you to create your ComboBox:

http://msdn.microsoft.com/library/d...ml/ExcelObj.asp
Regards,
Shikeb Ali
------------------------------------------
“Beware the fury of a patient man.”
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 18
Reputation: apchidara is an unknown quantity at this point 
Solved Threads: 0
apchidara apchidara is offline Offline
Newbie Poster

Re: importing data from excel to comboBox

 
0
  #3
Aug 30th, 2007
hi
this link is empty and also I searched I could not find the information I wanted please send me the exact link if you know . I would like to know how can I import the data column I want in my excel sheet , in the combo box .
thanks again
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 322
Reputation: Hamrick will become famous soon enough Hamrick will become famous soon enough 
Solved Threads: 33
Hamrick's Avatar
Hamrick Hamrick is offline Offline
Posting Whiz

Re: importing data from excel to comboBox

 
0
  #4
Aug 30th, 2007
and when I run my combo box will get filled with nSystem.Data.DataRowView
You set the data source but not the display member. The display member is the name of the column in the data table that you want to show in the list.
  1. ComboBox1.DataSource = dt.Tables( 0 )
  2. ComboBox1.DisplayMember = "Name"
The truth does not change according to our ability to stomach it.
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 44
Reputation: TaoistTotty is an unknown quantity at this point 
Solved Threads: 0
TaoistTotty TaoistTotty is offline Offline
Light Poster

Re: importing data from excel to comboBox

 
0
  #5
Aug 30th, 2007
apchidara, please can you let me have a fully working link - I am working on an application that needs to do a lot of work with Excel.
One thing I have learnt is it is not what you know, but knowing what you don't that makes the difference.
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 18
Reputation: apchidara is an unknown quantity at this point 
Solved Threads: 0
apchidara apchidara is offline Offline
Newbie Poster

Re: importing data from excel to comboBox

 
0
  #6
Aug 31st, 2007
Originally Posted by TaoistTotty View Post
apchidara, please can you let me have a fully working link - I am working on an application that needs to do a lot of work with Excel.
hi :
which code you need the excel connection code?
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 18
Reputation: apchidara is an unknown quantity at this point 
Solved Threads: 0
apchidara apchidara is offline Offline
Newbie Poster

Re: importing data from excel to comboBox

 
0
  #7
Aug 31st, 2007
hey hamrik
I did it for one comboBox it works and the second I wanted it to be filled with the other column and I put the name of that culumn but u know what ? the combo box will get filled with the previous column that means both ae the same here is the code:



Dim ComboBox2 As ComboBox
ComboBox1.DataSource = DtSet.Tables(0)
ComboBox1.DisplayMember = "Iso Standards"
ComboBox2.DataSource = DtSet.Tables(0)
ComboBox2.DisplayMember = "MVB Standard"
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 322
Reputation: Hamrick will become famous soon enough Hamrick will become famous soon enough 
Solved Threads: 33
Hamrick's Avatar
Hamrick Hamrick is offline Offline
Posting Whiz

Re: importing data from excel to comboBox

 
0
  #8
Aug 31st, 2007
There's no reason that should happen unless you did something else later in the code that changes the bindings.
The truth does not change according to our ability to stomach it.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 4689 | Replies: 7
Thread Tools Search this Thread



Tag cloud for VB.NET
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC