OleDbConnection Connection = new OleDbConnection ();
try { // Open a connection to the database Connection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + fileName.Text + ";" + "Persist Security Info=False;"; Connection.Open();
// Create an OleDb command, OleDbCommand command = new OleDbCommand(); command.Connection = Connection; command.CommandText = "SELECT * FROM Authors";
// Execute and return the rows in the data reader object OleDbDataReader dataReader; dataReader = command.ExecuteReader(CommandBehavior.CloseConnection);
int nFields = dataReader.FieldCount;
// Setup the columns in the listview using the fields in the table listView.Clear(); for (int i = 0; i < nFields; i++)