简体   繁体   中英

Import from excel to sqlite database

Using c# and sqlite

I want to click on a button, choose an excel spread sheet, .xls or xlsx, save it into the sqlite database and also display on a datagridview next to the button. A lot of the suggestions I see are only for rewriting all the data in the database to save it or saving it through the datagridview.

The problem with this is that I want to save the data from the spreadsheet on top of the existing data inside the database already and the datagridview needs to show all the data in the sqlite.

Any suggestions on how to go about it? I can export but just can't figure a way to import.

Any suggestions on how to go about it? I can export but just can't figure a way to import.

Ideally you should have UPLOAD Button , IMPORT Button and a DataGridView .

UPLOAD

Load your excel spreadsheet by locating it in somewhere else(folders) transform the excel spreadsheet into DataGridView .

IMPORT

Loop every row in DataGridView , and run insert statement to sqlite database. After all row has been insert, you may clear your DataGridView and read from sqlite database again.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM