1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
try
{
if(comboBox1.Text != string.Empty && textBox1.Text != string.Empty)
{
string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filePath + ";Extended Properties=\"Excel 8.0\";";
OleDbConnection connection = new OleDbConnection(connectionString);
string cmdText = "SELECT * FROM [Synthèse$]";
OleDbCommand command = new OleDbCommand(cmdText, connection);
command.Connection.Open();
OleDbDataReader reader = command.ExecuteReader();
if (reader.HasRows)
{
MessageBox.Show("Upload OK!");
while (reader.Read())
{
listBox1.Items.Add(reader[6].ToString());
//listBox1.Items.Add("{0}\t{1}", reader[0].ToString(), reader[1].ToString());
}
} |
Partager