The following Code call and display all excel sheets in a combobox and its working perfectly:
OpenFileDialog1.ShowDialog()
XlsPath.Text = OpenFileDialog1.FileName
Dim excelConnectionString As System.Data.OleDb.OleDbConnection = New System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & OpenFileDialog1.FileName & ";" + " Extended Properties=Excel 8.0")
excelConnectionString.Open()
ComboBox1.DataSource = GetExcelSheetNames(SVTest:="")
Dim cmd As New System.Data.OleDb.OleDbCommand("SELECT * FROM [Details$]", excelConnectionString)
Dim daCSV As New OleDbDataAdapter()
daCSV.SelectCommand = cmd
Dim dtCSV = New DataTable()
daCSV.Fill(dtCSV)
ListView1.Visible = True
ListBox2.Visible = True
ListView1.DataBindings.Add()
Dim index As Integer
index = ComboBox1.FindStringExact(0)
Label5.Text = ("Number of Column(s) : " & dtCSV.Columns.Count)
excelConnectionString.Close()
However, when i select a table from the list in the combobox,
I want it to display all the table columns in LstView1 with checkboxes........
How can i achieve that? pls guys, its urgent as am developing ETL Tool...
My code below:
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
Dim selectedItem As String
selectedItem = ComboBox1.SelectedItem
Me.ListviewBindingSource = New BindingSource
AddHandler Me.Load, AddressOf ComboBox1_SelectedIndexChanged
Me.ListView1.Dock = DockStyle.Bottom
Me.Controls.Add(Me.ListView1)
Me.ListviewBindingSource.DataSource = _dt.Columns(SelectedItem)
Me.ListView1.DataBindings.Add(New Binding("Text", _
Me.ListviewBindingSource, "", True))
Label5.Text = ("Number of Column(s) : " & ListView1.Items.Count)
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
For i = 1 To _dt.Columns.Count
ListView1.Items.Add(New ListViewItem(i))
ListView1.Items.Add(New ListViewItem(selectedItem))
Next i
Label5.Text = ("Number of Column(s) : " & ListView1.Items.Count)
End Sub
Error: Object reference not set to an instance of an object.
How can i do it? Can any1 correct the codings for me? I want it display all the field/column names/text in Listview1 checkboxes
I have tried with d 2 different approaches, but still couldn't get it to display any field names
Any answer will serve my interest and more.
Thanx guys