Visualizzazione dei risultati da 1 a 6 su 6

Discussione: c#excell

Visualizzazione discussione

  1. #1

    c#excell

    Salve mi serve aiuto, non so cosa mettere in command.text dove sta scritto sheet, grazie in anticipo

    codice:
    DataTable dt = new DataTable();
                string fileName = @"C:\Users\Domenico.DESKTOP-KDBNQN1\Downloads\prova.xlt";
                using (OleDbConnection conn = new OleDbConnection())
                {
                    conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + fileName + ";" + "Extended Properties='Excel 8.0;HDR=YES;'";
                    using (OleDbCommand comm = new OleDbCommand())
                    {
                        comm.CommandText = "SELECT Id,Nome,Cognome  FROM[Sheet1$]";
    
    
    
    
    
    
                        comm.Connection = conn;
    
    
                        using (OleDbDataAdapter da = new OleDbDataAdapter())
                        {
                            da.SelectCommand = comm;
                            da.Fill(dt);
                            
                        }
    
    
                    }
                }
            }
    Ultima modifica di LeleFT; 17-01-2018 a 19:16 Motivo: Aggiunti i tag CODE

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.