1. Purpose
Use the ADO to connect SQL Server database, delete and change the data table.
2. Requirements
Pass in SQL statements and parameters to get a result set or dictionary set
3. Approach to implementation
Encapsulates the parameterized method and the SqlDataReader value method of the ADO object, adds the passed-in parameter to the SqlParameter, and places the fetched value in the dictionary set or the object list
Parameter name is found by locating the parameter ID in the SQL statement, and the parameter value is found by the name or the location passed in by the parameter. Then join SqlParameter.
When values are fetched, each row of data is read by SqlDataReader, with the column name key and the value added to the dictionary list. or find the corresponding entity class property name based on the column name, then assign a value.
Use the regular to find the parameter names in the SQL statement. Use the PropertyInfo class to find the corresponding attribute of the entity class based on the parameter name, and then take the assignment.
Close the database connection after executing the statement, and open the database connection before executing the statement. If there is a transaction, open the connection when the transaction Start method is invoked, and close the connection after the rollback or commit.
4. How to use
SQL Server Db=new SQL Server (CONNSTR);
String sql= "Select name from Employee where Id=:id and Isdel=:isdel";
Employee[] Data=db. Executequery<employee> (sql,1,0)
5. Source code
Https://github.com/mirrortom/DBM
database table additions and deletions help class