⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cdbmanager.cs

📁 Teacher Manager System
💻 CS
字号:
using System;
using System.Data;
using System.Configuration;
using System.Data.SqlClient;

namespace tw.org.iii.crm.data
{
    
    public class CDbManager
    {
        private SqlConnection iv_conn;
        private string iv_str資料庫連接字串="";

        public string 資料庫連接字串
        {
            get
            {
                if ("".Equals(iv_str資料庫連接字串))
                    iv_str資料庫連接字串 = @"Data Source=CR1-A20;Initial Catalog=TMBank;Integrated Security=True";
                return iv_str資料庫連接字串; }
            set { iv_str資料庫連接字串 = value; }
        }

        public SqlConnection getConnection()
        {
            if (iv_conn == null)
            {
                iv_conn = new SqlConnection();
                iv_conn.ConnectionString = this.資料庫連接字串;               

            }
            if (iv_conn.State == ConnectionState.Closed)
            
                iv_conn.Open();
            return iv_conn; 
                               
        
        }
        public void executeBySql(string p_strSql)
        {
            SqlCommand l_comm = new SqlCommand(p_strSql, getConnection());
            l_comm.ExecuteNonQuery();
            getConnection().Close();
        
        
        }
        public DataTable queryBySql(string p_strSql)
        {

            SqlDataAdapter l_adapter = new SqlDataAdapter(p_strSql, getConnection());
            DataSet l_ds = new DataSet();
            l_adapter.Fill(l_ds);
            getConnection().Close();
            return l_ds.Tables[0];
        
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -