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

Recommended Answers

All 7 Replies

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

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.

ComboBox1.DataSource = dt.Tables( 0 )
ComboBox1.DisplayMember = "Name"

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.

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?

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"

There's no reason that should happen unless you did something else later in the code that changes the bindings.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.