I learned how to operate data tables on the front-end interface this week.
1. Mind Map
Ii. Knowledge POint Description
Frontend and backend interfaces are required because front-end pages only provide views and NO content, while the backend only provides content, it is to place the back-end content on the reserved position of the front-end page.
Both use the datagridview Control
- Executenonquery, which calls the SQL command, to execute the command, write data to the database, and return the number of affected rows;
- Capture SQL exceptions. If the SQL exception number is 2627, the primary key/unique constraint is violated, that is, the duplicate value is inserted;
- The stored procedure calls the SQL connection method createcommand to create an SQL command. This command is bound to an SQL connection. It specifies the command Text of the SQL command. The command text is the name of the stored procedure; set the SQL command type to Stored Procedure
- The dategridview control is also used for deletion.
- Update record: Call the SQL command method executereader to execute the command and obtain the data reader. Call the data reader method getordinal to obtain the corresponding index values of each column. Also, use the datagridview control.
- Query records: Call the SQL command method executereader to execute the command and obtain the data reader. Call the data reader method getordinal to obtain the corresponding index values of each column. The data table also uses the datagridview control.
Step 1: Database Connection
I am using code to connect to the database. below is my code content.
The second part is data input.
Then the running result is displayed, indicating that the data is successfully input.
Operate data tables on the front-end interface