1

Given the fact that Excel and Access are compatible in some level, is there a way to import data from an excel file to an Access Database programmatically, without reading the file and inserting data, record by record?

0

1 Answer 1

5

Very roughly:

string ConnString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=Z:\Docs\Test.accdb";
OleDbConnection conn = new OleDbConnection(ConnString);
conn.Open();
string sql = @"select * into newxl from [Excel 8.0;HDR=YES;DATABASE=Z:\Docs\Test.xlsx].[Sheet1$] s;";

OleDbCommand cmd = new OleDbCommand();
cmd.Connection = conn;
cmd.CommandText = sql;
cmd.ExecuteNonQuery();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.