Skip to content

How to get excel data to ms access

gaurav kaushik

Asked Mar 18, 2010, 9:04 PM EDT1 answer
Share
LinkedInX
i have  a project  school managment system..
i want  to copy all  excel data  to the project  because most  of the college maintains their record in excel...........
i   used  msaccess database............
plz provide   me some help... 

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • Hirendra Sisodiya
    0
    try this :
       System.Data.OleDb.OleDbConnection MyConnection ;
        System.Data.DataSet DtSet
        System.Data.OleDb.OleDbDataAdapter MyCommand ;
        MyConnection = new System.Data.OleDb.OleDbConnection("Connection String"); 
         // put our connection string on the place of "ConnectionString" for more information of excel connection string try this link:  http://www.connectionstrings.com/excel
           //and suppse that Sheet1 is your spreadsheet name

        MyCommand = new System.Data.OleDb.OleDbDataAdapter("select * from [Sheet1$]", MyConnection);
        MyCommand.TableMappings.Add("Table", "TestTable");
        DtSet = new System.Data.DataSet();
        MyCommand.Fill(DtSet);
        MyConnection.Close();

    now you can save dataset in to access database easily.
     
    thanks
     
    mark as answere if you like my answere
    0