问题描述
singSystem;usingSystem.Collections.Generic;usingSystem.Text;usingSystem.Data;usingSystem.Data.SqlClient;namespaceBarManageSys{classDataBase{publicSqlConnectionsqlConn;publicstaticstringsConn="DataSource=.;AttachDbFilename=|DataDirectory|BarManageDB.mdf;IntegratedSecurity=SSPI";publicvoidDispose(){Dispose(true);GC.SuppressFinalize(true);}protectedvoidDispose(booldisposing){if(!disposing){return;}if(sqlConn!=null){sqlConn.Dispose();sqlConn=null;}}publicvoidOpen(){sqlConn=newSqlConnection(sConn);sqlConn.Open();}publicvoidClose(){if(sqlConn!=null)sqlConn.Close();}publicDataViewRunSelectSQL(stringsSQLString){this.Open();DataSetSqlDS=newDataSet();SqlDataAdapterSqlDA=newSqlDataAdapter(sSQLString,this.sqlConn);SqlDA.Fill(SqlDS);returnSqlDS.Tables[0].DefaultView;}publicvoidRunDelOrInsSQl(stringsSQLString){this.Open();SqlCommandSqlComm=newSqlCommand(sSQLString,this.sqlConn);SqlComm.ExecuteNonQuery();}publicDataBase(){}}}