943,917 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 6653
  • VB.NET RSS
Aug 28th, 2007
0

importing data from excel to comboBox

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
apchidara is offline Offline
18 posts
since Aug 2007
Aug 28th, 2007
0

Re: importing data from excel to comboBox

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
Reputation Points: 10
Solved Threads: 0
Light Poster
shikeb is offline Offline
26 posts
since Jul 2007
Aug 30th, 2007
0

Re: importing data from excel to comboBox

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
apchidara is offline Offline
18 posts
since Aug 2007
Aug 30th, 2007
0

Re: importing data from excel to comboBox

Quote ...
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.
vb.net Syntax (Toggle Plain Text)
  1. ComboBox1.DataSource = dt.Tables( 0 )
  2. ComboBox1.DisplayMember = "Name"
Reputation Points: 180
Solved Threads: 34
Posting Whiz
Hamrick is offline Offline
322 posts
since Jun 2007
Aug 30th, 2007
0

Re: importing data from excel to comboBox

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.
Reputation Points: 10
Solved Threads: 0
Light Poster
TaoistTotty is offline Offline
46 posts
since Aug 2007
Aug 31st, 2007
0

Re: importing data from excel to comboBox

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?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
apchidara is offline Offline
18 posts
since Aug 2007
Aug 31st, 2007
0

Re: importing data from excel to comboBox

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"
Reputation Points: 10
Solved Threads: 0
Newbie Poster
apchidara is offline Offline
18 posts
since Aug 2007
Aug 31st, 2007
0

Re: importing data from excel to comboBox

There's no reason that should happen unless you did something else later in the code that changes the bindings.
Reputation Points: 180
Solved Threads: 34
Posting Whiz
Hamrick is offline Offline
322 posts
since Jun 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: Shortcut
Next Thread in VB.NET Forum Timeline: Creating Table using SQL query from wondows Form





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC