timetoquitcoding
timetoquitcoding

Reputation: 45

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.

Upvotes: 0

Views: 1281

Answers (1)

Raynoceros
Raynoceros

Reputation: 386

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.

Upvotes: 1

Related Questions