Some time ago, I have been learning to use ado.net to realize the addition, deletion, modification and query of the database. After more than two months, I finally wrote it. Although the function is relatively simple, it takes a lot of effort, alas, a handful of bitter tears~, the purpose of writing essays is to record what I have learned.
Entering the topic, I used a layered approach to build this project. The project structure is as follows:
The following is the simplest and most rude way to sort out the ideas, and paste the code above.
Dal layer code:
Bll layer code:
Code in Controller:
Part of the code in the Index view:
Part of the code of the Update view (the update view is the page that jumps during the "modify" operation), and jumps to the index page by submitting the form:
The above code roughly reflects the operation of adding, deleting, modifying and checking the database using ado.net.