DBHelp data processing class, dbhelp Data Processing
Using System; using System. collections. generic; using System. linq; using System. text; using System. threading. tasks; using System. data. sqlClient; using MyShoolModels; namespace MyShoolDAL {public class DBhelper {string conn = "Data Source = .; initial Catalog = MySchool; User ID = sa "; SqlConnection SC; public SqlConnection SC // connection {get {if (SC = null) {SC = new SqlConnection (conn );} return SC ;}} public void OpenSc () // open {if (SC. state = System. data. connectionState. broken | SC. state = System. data. connectionState. closed) {SC. close (); SC. open () ;}} public void CloseSc () // close {if (SC. state = System. data. connectionState. broken | SC. state = System. data. connectionState. open) {SC. close () ;}} public int ExecuteQue (string SQL, SqlParameter [] paras) {SqlCommand cmd = new SqlCommand (SQL, SC); cmd. parameters. addRange (paras); int resul = cmd. executeNonQuery (); return resul ;}}}