Torna al Thread

Dim comm As OleDbCommand = New OleDbCommand("Select * from [Foglio1$];") Dim excelLettura As OleDbDataReader 'Imposto la stringa di connesisione Using conn As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\\varie\\LetturaExcel.xlsx;Extended Properties=Excel 12.0 Xml;") Try 'apro la connessione ed eseguo la query conn.Open() comm.Connection = conn excelLettura = comm.ExecuteReader() 'per ogni record che trovo visualizzo a video il risultato Dim Nome As String = "" Dim Cognome As String = "" While (excelLettura.Read()) Nome = excelLettura("Nome").ToString() Cognome = excelLettura("Cognome").ToString() MessageBox.Show("Nome: " + Nome + " Cognome: " + Cognome) Application.DoEvents() End While excelLettura.Dispose() comm.Dispose() Catch ex As Exception MessageBox.Show("Errore: " + ex.Message) Finally 'chiudo la connessione If (conn.State = ConnectionState.Open) Then conn.Close() End Try End Using
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5