Why won't this DataAdapter insert rows into the database?

前端 未结 2 1955
孤独总比滥情好
孤独总比滥情好 2021-01-21 23:05

So I have a situation where I am using a SqlDataAdapter to insert rows into a table in a SQL Server 2014 database.

The source of the data is an Excel spreadsheet.

<
2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-21 23:59

    I had the same issue, and the solution was quite simple, once you've seen it... I had my Database in Visual studio, and its property "Copy to Output Directory" was set to "Copy always", instead of "Do not copy". So everytime I was running my code, the database was erased!

    Solution : - modify your connection string so it points directly to your database - Change your database property to "Do not copy"

提交回复
热议问题