locked
Select excel file and insert rows from file to Database RRS feed

  • Question

  • User-1546582794 posted

    I would like the user to select an excel file, that is accordingly to specifications for columns, and that when selected I can insert the data from this file, it's rows, into a table in my Oracle Database.


    Using: ASP.NET 2.0, Visual Basic 2005, Oracle database 10gR2

    Thursday, July 9, 2009 12:20 PM

All replies

  • User191633014 posted

    Use this to get Data from Excel:

    using System.Data;
    using System.Data.OleDb;
     
     
            String sConnectionString =string.Format(  "Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties=Excel 8.0;",ExcelFile);
            OleDbConnection objConn = new OleDbConnection(sConnectionString);
            objConn.Open();
            OleDbCommand objCmdSelect = new OleDbCommand("SELECT * FROM [Sheet1$]", objConn);
            OleDbDataAdapter objAdapter1 = new OleDbDataAdapter();
            objAdapter1.SelectCommand = objCmdSelect;
            DataSet objDataset1 = new DataSet();
            objAdapter1.Fill(objDataset1);
            objConn.Close();

    Friday, July 10, 2009 5:37 AM