Dim boolHeaderRow As Boolean = False
Dim strFileConnectionString As String = ';';
Dim FileDirectory, FileName As String
Dim Header As String = ';';
FileDirectory = ';REPLACE WITH YOUR FILE DIRECTORY LOCATION';
FileName = ';REPLACE WITH YOUR FILE NAME';
Header = ';REPLACE WITH YES OR NO. Does the file contain a header row?';
Dim ConnectionString, CommandText As String
Dim conn As OleDb.OleDbConnection
Dim Command As OleDb.OleDbCommand
ConnectionString = ';Provider=Microsoft.Jet.OLEDB.4.0;Data Source='; _
%26amp; FileDirectory %26amp; ';\;Extended Properties='text;HDR='; %26amp; Header %26amp; ';'';
CommandText = ';select TOP 10 * from '; %26amp; FileName
conn = New System.Data.OleDb.OleDbConnection _
(ConnectionString)
Command = New System.Data.OleDb.OleDbCommand _
(CommandText, conn)
conn.Open()
Dim da As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter _
(CommandText, conn)
Dim ds As DataSet = New DataSet
da.Fill(ds, ';Employees';)
Dim ListBox As New ListBox
'Change this to your listbox
With ListBox
.DataSource = ds
.DataTextField = ';F1';
.DataValueField = ';F2';
.DataBind()
End With
conn.Close()
No comments:
Post a Comment