0

I use database-first approach in ASP.NET Core MVC. Now my website can show the table from my database, also it has Create.cshtml, Delete.cshtml, Details.cshtml, and Edit.cshtml pages.

I want to add a function to allow the user to select any .CSV file on the computer, then read and convert it and update the data in the database, but I have no idea how to do this.

I have seen two way from https://www.postgresqltutorial.com/import-csv-file-into-posgresql-table/

but I think it can't meet my needs. Does anyone have any idea?

GG6565
  • 138
  • 10
  • What you want is to make an upload function, and then map the uploaded CSV file to our table in the database, right? – Tupac Aug 25 '21 at 07:42
  • TO Chaodeng: Yes, it is what I want. – GG6565 Aug 25 '21 at 07:46
  • There are many ideas in this post, which may be useful to you.https://stackoverflow.com/questions/43203353/upload-csv-file-then-mapped-to-tables-in-database – Tupac Aug 25 '21 at 07:59
  • TO Chaodeng: OK, I will read it. Thanks! – GG6565 Aug 25 '21 at 08:10
  • I have read the data. but I still have doubt. Now I can upload .csv file to folder, but how can I import Database.... – GG6565 Aug 27 '21 at 06:41
  • Before that, I would like to ask why you don’t use a visual connection tool to complete it. Isn’t it more convenient? – Tupac Aug 27 '21 at 06:46
  • You can refer to [this doc](https://www.npgsql.org/doc/copy.html) that shows how to bulk import data to PostgreSQL with using [Npgsql](https://www.nuget.org/packages/Npgsql/). – Fei Han Aug 29 '21 at 06:40

0 Answers0