`
阅读更多

using System;
using System.Data;
using System.Configuration;
using System.Web;
//using System.Web.Security;
//using System.Web.UI;
//using System.Web.UI.WebControls;
//using System.Web.UI.WebControls.WebParts;
//using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Text;
using System.Collections;
namespace domain.SQLDB
{

    public class DbAccess
    {
        SqlConnection conn = null;
        SqlCommand cmd = null;
        public DbAccess()
        {
            //
            // TODO: 在此处添加构造函数逻辑
            //
            conn = new SqlConnection();
            conn.ConnectionString =  Convert.ToString(System.Configuration.ConfigurationSettings.AppSettings["datasource"]);
            //conn.ConnectionString = "initial catalog=idyan_new;data source=.;user id=bt;password=btbtbtbt;Connect Timeout=5000";
            cmd = new SqlCommand();
            cmd.Connection = conn;
            cmd.CommandTimeout = 0;
    
        }
        public DbAccess(string constr)
        {
         
            //
            // TODO: 在此处添加构造函数逻辑
            //
            conn = new SqlConnection();
            conn.ConnectionString = constr;// "initial catalog=idyan_new;data source=.;user id=bt;password=btbtbtbt";
            cmd = new SqlCommand();
            cmd.Connection = conn;
            cmd.CommandTimeout = 0;
         
        }
        /// <summary>
        /// 获取数据根据sql语句
        /// </summary>
        /// <param name="sql"></param>
        /// <returns></returns>
        public DataTable GetTable(string sql)
        {
            DataSet ds = new DataSet();
            try
            {
                cmd.CommandText = sql;
                cmd.CommandType = CommandType.Text;
                SqlDataAdapter da = new SqlDataAdapter();
                da.SelectCommand = cmd;
                da.Fill(ds);
            }
            catch (Exception ex)
            {

                this.ShowError(ex.Message);
                return null;

            }
            return ds.Tables[0] ?? new DataTable();
        }
        /// <summary>
        /// 获取数据根据sql语句
        /// </summary>
        /// <param name="sql"></param>
        /// <returns></returns>
        public DataSet GetDataSet(string sql)
        {
            DataSet ds = new DataSet();

            try
            {
                cmd.CommandText = sql;
                cmd.CommandType = CommandType.Text;
                SqlDataAdapter da = new SqlDataAdapter();
                da.SelectCommand = cmd;

                da.Fill(ds);
            }
            catch (Exception ex)
            {

                this.ShowError(ex.Message);
                return null;

            }
            return ds;
        }
        /// <summary>
        /// 获取数据根据sql语句
        /// </summary>
        /// <param name="sql"></param>
        /// <returns></returns>
        public DataSet GetDataSet(string sql,SqlParameter[] pas)
        {
            DataSet ds = new DataSet();

            try
            {
                cmd.Parameters.Clear();
                cmd.CommandText = sql;
                foreach (SqlParameter pa in pas)
                {
                    cmd.Parameters.Add(pa);
                }
                cmd.CommandType = CommandType.Text;
                SqlDataAdapter da = new SqlDataAdapter();
                da.SelectCommand = cmd;

                da.Fill(ds);
            }
            catch (Exception ex)
            {

                this.ShowError(ex.Message);
                return null;

            }
            return ds;
        }
        /// <summary>
        /// 获取数据根据sql语句 带参数 的
        /// </summary>
        /// <param name="sql"></param>
        /// <param name="pas"></param>
        /// <returns></returns>
        public DataTable GetTable(string sql, params SqlParameter[] pas)
        {
            DataSet ds = new DataSet();
            try
            {
                cmd.CommandText = sql;
                cmd.CommandType = CommandType.Text;
                SqlDataAdapter da = new SqlDataAdapter();
                da.SelectCommand = cmd;
                cmd.Parameters.Clear();

                foreach (SqlParameter temppa in pas)
                {
                    cmd.Parameters.Add(temppa);
                }


                da.Fill(ds);
            }
            catch (Exception ex)
            {

                this.ShowError(ex.Message);
                return null;
            }
            return ds.Tables[0] ?? new DataTable();
        }
        /// <summary>
        /// 获取数据根据sql语句 带参数 的
        /// </summary>
        /// <param name="sql"></param>
        /// <param name="pas"></param>
        /// <returns></returns>
        public DataTable GetProcTable(string procname, params SqlParameter[] pas)
        {
            DataSet ds = new DataSet();
            try
            {
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = procname;
                //cmd.CommandText = sql;
                SqlDataAdapter da = new SqlDataAdapter();
                da.SelectCommand = cmd;
                cmd.Parameters.Clear();

                foreach (SqlParameter temppa in pas)
                {
                    cmd.Parameters.Add(temppa);
                }
              


                da.Fill(ds);
            }
            catch (Exception ex)
            {

                this.ShowError(ex.Message);
                return null;
            }
            return ds.Tables[0] ?? new DataTable();
        }
        /// <summary>
        /// 获取数据根据sql语句 带参数 的
        /// </summary>
        /// <param name="sql"></param>
        /// <param name="pas"></param>
        /// <returns></returns>
        public DataTable GetProcCursorTable(string procname, params SqlParameter[] pas)
        {
            DataSet ds = new DataSet();
            try
            {
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = procname;
                //cmd.CommandText = sql;
                SqlDataAdapter da = new SqlDataAdapter();
                da.SelectCommand = cmd;
                cmd.Parameters.Clear();

                foreach (SqlParameter temppa in pas)
                {
                    cmd.Parameters.Add(temppa);
                }

 

                da.Fill(ds);
            }
            catch (Exception ex)
            {

                this.ShowError(ex.Message);
                return null;
            }
            return ds.Tables[1] ?? new DataTable();
        }
        /// <summary>
        /// 获取数据根据sql语句 带参数 的
        /// </summary>
        /// <param name="sql"></param>
        /// <param name="pas"></param>
        /// <returns></returns>
        public int  GetProcState(string procname, params SqlParameter[] pas)
        {
            int state = 0;
            try
            {
                OpenConn();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = procname;
                cmd.Parameters.Clear();
                foreach (SqlParameter temppa in pas)
                {
                    cmd.Parameters.Add(temppa);
                }
                cmd.ExecuteNonQuery();
                CloseConn();
                state = Convert.ToInt32(pas[pas.Length - 1].Value);
             
            }
            catch
            {
                return 0;
            }
            return state;
        }
        /// <summary>
        /// 获取数据根据sql语句 带参数 的
        /// </summary>
        /// <param name="sql"></param>
        /// <param name="pas"></param>
        /// <returns></returns>
        public int GetProcStateNo(string procname, params SqlParameter[] pas)
        {
            int state = 0;
            try
            {
                OpenConn();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = procname;
                cmd.Parameters.Clear();
                foreach (SqlParameter temppa in pas)
                {
                    cmd.Parameters.Add(temppa);
                }
                cmd.ExecuteNonQuery();
                CloseConn();
                state = 1;
               // state = Convert.ToInt32(pas[pas.Length - 1].Value);

            }
            catch(Exception ex)
            {

                return 0;
            }
            return state;
        }
        /// <summary>
        /// 根据sql语句返回跟新状态
        /// </summary>
        /// <param name="sql"></param>
        /// <returns></returns>
        public bool GetState(string sql)
        {
            bool succ = false;
            try
            {
                cmd.CommandType = CommandType.Text;
                cmd.CommandText = sql;
                OpenConn();
                succ = cmd.ExecuteNonQuery() > 0 ? (true) : (false);
                CloseConn();
            }
            catch (Exception ex)
            {

                this.ShowError(ex.Message);
                return false;
            }
            return succ;

        }
        /// <summary>
        /// 根据sql语句返回跟新状态带参数的
        /// </summary>
        /// <param name="sql">sql语句</param>
        /// <param name="pas">参数的集合</param>
        /// <returns></returns>
        public bool GetState(string sql, params SqlParameter[] pas)
        {
            bool succ = false;
            try
            {
                cmd.CommandType = CommandType.Text;
                cmd.CommandText = sql;
                cmd.Parameters.Clear();

                foreach (SqlParameter temppa in pas)
                {
                    cmd.Parameters.Add(temppa);
                }
                OpenConn();
                succ = cmd.ExecuteNonQuery() > 0 ? (true) : (false);
                CloseConn();
            }
            catch (Exception ex)
            {

               // this.ShowError(ex.Message);
                //using (System.IO.StreamWriter sw = new System.IO.StreamWriter("D:\\error2008.txt"))
                //{
                //    sw.Write(ex.Message);
                //    sw.Flush();
                //}
                return false;
            }
            return succ;

        }
        /// <summary>
        /// 根据sql语句返回第一个单元格的数据
        /// </summary>
        /// <param name="sql"></param>
        /// <returns></returns>
        public string GetOne(string sql)
        {
            string res = "";
            try
            {
                cmd.CommandType = CommandType.Text;
                cmd.CommandText = sql;
                OpenConn();
                res = cmd.ExecuteScalar() == null ? ("") : (Convert.ToString(cmd.ExecuteScalar()));
                CloseConn();
            }
            catch (Exception ex)
            {

                this.ShowError(ex.Message);
                return null;
            }
            return res;
        }
        /// <summary>
        ///  根据sql语句返回第一个单元格的数据带参数的
        /// </summary>
        /// <param name="sql"></param>
        /// <param name="pas"></param>
        /// <returns></returns>
        public string GetOne(string sql, params SqlParameter[] pas)
        {
            string res = "";
            try
            {
                cmd.CommandType = CommandType.Text;
                cmd.CommandText = sql;
                cmd.Parameters.Clear();

                foreach (SqlParameter temppa in pas)
                {
                    cmd.Parameters.Add(temppa);
                }
                OpenConn();
                res = cmd.ExecuteScalar() == null ? ("") : (Convert.ToString(cmd.ExecuteScalar()));
                CloseConn();
            }
            catch (Exception ex)
            {

                this.ShowError(ex.Message);
                return null;
            }
            return res;
        }
        /// <summary>
        /// 返回数据的DataReader
        /// </summary>
        /// <param name="sql"></param>
        /// <returns></returns>
        public SqlDataReader GetDataReader(string sql)
        {
            SqlDataReader dr = null;
            try
            {
                cmd.CommandType = CommandType.Text;
                conn.Open();
                cmd.CommandText = sql;
                dr = cmd.ExecuteReader();
            }
            catch (Exception ex)
            {

                this.ShowError(ex.Message);
                return null;
            }
            return dr;
        }
        /// <summary>
        /// 返回数据的DataReader带参数的
        /// </summary>
        /// <param name="sql"></param>
        /// <param name="pas"></param>
        /// <returns></returns>
        public SqlDataReader GetDataReader(string sql, params SqlParameter[] pas)
        {
            SqlDataReader dr = null;
            try
            {
                cmd.CommandType = CommandType.Text;
                conn.Open();
                cmd.Parameters.Clear();

                foreach (SqlParameter temppa in pas)
                {
                    cmd.Parameters.Add(temppa);
                }

                cmd.CommandText = sql;
                dr = cmd.ExecuteReader();
            }
            catch (Exception ex)
            {

                this.ShowError(ex.Message);
                return null;
            }
            return dr;
        }
        /// <summary>
        /// 事务处理函数
        /// </summary>
        /// <param name="al"></param>
        /// <returns></returns>
        public bool GetTranState(ArrayList al)
        {
            cmd.CommandType = CommandType.Text;
            OpenConn();
            SqlTransaction tran = conn.BeginTransaction();
            cmd.Transaction = tran;
            try
            {
                for (int i = 0; i < al.Count; i++)
                {
                    cmd.CommandText = Convert.ToString(al[i]);
                    cmd.ExecuteNonQuery();
                }
           
                tran.Commit();  
                CloseConn();
            }
            catch (Exception ex)
            {

                tran.Rollback();
                return false;
            }
            return true;

        }
        /// <summary>
        /// 事务处理函数
        /// </summary>
        /// <param name="al"></param>
        /// <returns></returns>
        public bool GetTranStateParameter(ArrayList al)
        {
            cmd.CommandType = CommandType.Text;
            OpenConn();
            SqlTransaction tran = conn.BeginTransaction();
            cmd.Transaction = tran;
            try
            {
                for (int i = 0; i < al.Count; i++)
                {
                    SqlTranModel stm = (SqlTranModel)al[i];
                    cmd.CommandText = Convert.ToString(stm.Sql);
                    SqlParameter[] pas = stm.Pas;
                    cmd.Parameters.Clear();
                    foreach (SqlParameter temp in pas)
                    {
                        cmd.Parameters.Add(temp);
                    }
                    cmd.ExecuteNonQuery();
                }

                tran.Commit();
                CloseConn();
            }
            catch (Exception ex)
            {

                tran.Rollback();
                return false;
            }
            return true;

        }
        /// <summary>
        /// 分页函数
        /// </summary>
        /// <param name="pagesize"></param>
        /// <param name="columns"></param>
        /// <param name="tablename"></param>
        /// <param name="pid"></param>
        /// <param name="order"></param>
        /// <param name="current"></param>
        /// <returns></returns>
        public DataTable GetPageData(int current,int pagesize,string columns,string tablename,string pid,string where,string order)
        {
            current = current-1>=0?(current-1):(0);
            string sql = string.Format("select top {0} {1} from {2} where 1=1 and {3} not in(select top {4}{3} from {2} where 1=1{5}  order by {6}){5} order by {6}", pagesize, columns, tablename, pid, current * pagesize,where, order);
            return GetTable(sql);
        }
        /// <summary>
        /// 分页存储过程的调用
        /// </summary>
        /// <param name="current"></param>
        /// <param name="pagesize"></param>
        /// <param name="columns"></param>
        /// <param name="tablename"></param>
        /// <param name="pid"></param>
        /// <param name="where"></param>
        /// <param name="order"></param>
        /// <returns></returns>
        public DataTable GetProcPageData(int current, int pagesize, string columns, string tablename, string pid, string where, string order,string ordertype)
        {
            SqlParameter[] pas = { new SqlParameter("@PageIndex", current), new SqlParameter("@PageSize", pagesize), new SqlParameter("@Columns", columns), new SqlParameter("@Tablename", tablename), new SqlParameter("@Where", where), new SqlParameter("@Order", order), new SqlParameter("@OrderType", ordertype), new SqlParameter("@Pid", pid)};
            return GetProcTable("Pages", pas);
            //current = current - 1 >= 0 ? (current - 1) : (0);
            //string sql = string.Format("select top {0} {1} from {2} where 1=1 and {3} not in(select top {4}{3} from {2} where 1=1{5}  order by {6}){5} order by {6}", pagesize, columns, tablename, pid, current * pagesize, where, order);
            //return GetTable(sql);
        }
        /// <summary>
        /// 分页存储过程的调用
        /// </summary>
        /// <param name="current"></param>
        /// <param name="pagesize"></param>
        /// <param name="columns"></param>
        /// <param name="tablename"></param>
        /// <param name="pid"></param>
        /// <param name="where"></param>
        /// <param name="order"></param>
        /// <returns></returns>
        public DataTable GetProcData(int current, int pagesize, string columns, string tablename, string pid, string where, string order,string resultCount, string distinct)
        {
            SqlParameter[] pas = { new SqlParameter("@TableNames", SqlDbType.NVarChar, 200), new SqlParameter("@PrimaryKey", SqlDbType.NVarChar, 100), new SqlParameter("@Order", SqlDbType.NVarChar, 200), new SqlParameter("@CurrentPage", SqlDbType.Int), new SqlParameter("@PageSize", SqlDbType.Int), new SqlParameter("@Fields", SqlDbType.NVarChar, 800), new SqlParameter("@Filter", SqlDbType.NVarChar, 1000), new SqlParameter("@ResultCount", SqlDbType.NVarChar, 12), new SqlParameter("@distinct", SqlDbType.NVarChar, 12) };
            pas[0].Value = tablename;
            pas[1].Value = pid;
            pas[2].Value = order;
            pas[3].Value = current;
            pas[4].Value = pagesize;
            pas[5].Value = columns;
            pas[6].Value = where;
            pas[7].Value = resultCount;
            pas[8].Value = distinct;
            return this.GetProcTable("Pages", pas);
            //SqlParameter[] parameters = {
            //                                new SqlParameter("@TableNames",SqlDbType.VarChar,8000),
            //                                new SqlParameter("@PrimaryKey", SqlDbType.VarChar,8000),
            //                                new SqlParameter("@Order", SqlDbType.VarChar,8000),
            //                                new SqlParameter("@CurrentPage",SqlDbType.Int),
            //                                new SqlParameter("@PageSize", SqlDbType.Int),
            //                                new SqlParameter("@Fields",SqlDbType.VarChar,8000),
            //                                new SqlParameter("@Filter", SqlDbType.VarChar,8000),
            //                                new SqlParameter("@Group", SqlDbType.VarChar,8000)
            //                            };
            //parameters[0].Value = tablename;
            //parameters[1].Value = pid;
            //parameters[2].Value = order;
            //parameters[3].Value = current;
            //parameters[4].Value = pagesize;
            //parameters[5].Value = columns;
            //parameters[6].Value = where;
            //parameters[7].Value = "";
            //DataSet ds = DbHelperSQL.RunProcedure("Pages", parameters, "data");

            //return ds.Tables["data"];//
            //return GetProcTable("Pages", pas);
            //current = current - 1 >= 0 ? (current - 1) : (0);
            //string sql = string.Format("select top {0} {1} from {2} where 1=1 and {3} not in(select top {4}{3} from {2} where 1=1{5}  order by {6}){5} order by {6}", pagesize, columns, tablename, pid, current * pagesize, where, order);
            //return GetTable(sql);
        }
        /// <summary>
        /// 分页存储过程的调用
        /// </summary>
        /// <param name="current"></param>
        /// <param name="pagesize"></param>
        /// <param name="columns"></param>
        /// <param name="tablename"></param>
        /// <param name="pid"></param>
        /// <param name="where"></param>
        /// <param name="order"></param>
        /// <returns></returns>
        public DataTable GetProcAdminData(int current, int pagesize, string columns, string tablename, string pid, string where, string order,string resultCount, string distinct)
        {
            SqlParameter[] pas = { new SqlParameter("@TableNames", SqlDbType.NVarChar, 200), new SqlParameter("@PrimaryKey", SqlDbType.NVarChar, 100), new SqlParameter("@Order", SqlDbType.NVarChar, 200), new SqlParameter("@CurrentPage", SqlDbType.Int), new SqlParameter("@PageSize", SqlDbType.Int), new SqlParameter("@Fields", SqlDbType.NVarChar, 800), new SqlParameter("@Filter", SqlDbType.NVarChar, 200), new SqlParameter("@ResultCount", SqlDbType.NVarChar, 24), new SqlParameter("@Distinct", SqlDbType.NVarChar, 12) };
            pas[0].Value = tablename;
            pas[1].Value = pid;
            pas[2].Value = order;
            pas[3].Value = current;
            pas[4].Value = pagesize;
            pas[5].Value = columns;
            pas[6].Value = where;
            pas[7].Value = resultCount;
            pas[8].Value = distinct;
            return this.GetProcTable("Pages", pas);
    
        }
        /// <summary>
        /// 打开连接
        /// </summary>
        public void OpenConn()
        {
            if (conn.State != ConnectionState.Open)
            {
                try
                {
                    conn.Open();
                }
                catch (Exception ex)
                {

                    this.ShowError(ex.Message);
                    return;
                }
            }
        }
        /// <summary>
        /// 关闭连接
        /// </summary>
        public void CloseConn()
        {
            if (conn.State != ConnectionState.Closed)
            {
                try
                {
                    conn.Close();
                
                }
                catch (Exception ex)
                {

                    this.ShowError(ex.Message);
                    return;
                }
            }
        }
        public void DisposeConn()
        {
            try
            {
                if (conn.State != ConnectionState.Closed)
                {
                    try
                    {
                        conn.Close();

                    }
                    catch (Exception ex)
                    {

                        this.ShowError(ex.Message);
                        return;
                    }
                }
            }
            catch
            {
 
            }
        }
    
        /// <summary>
        /// 弹出错误的信息
        /// </summary>
        /// <param name="err"></param>
        public void ShowError(string err)
        {
          //  System.Web..Current.Response.Write(Script(err, ""));
        }
        /// <summary>
        /// 显示信息
        /// </summary>
        /// <param name="err"></param>
        public void ShowMessage(string mes, string loc)
        {
           // System.Web.HttpContext.Current.Response.Write(Script(mes, loc));
        }
        /// <summary>
        /// javascript脚本
        /// </summary>
        /// <param name="mess"></param>
        /// <param name="loc"></param>
        /// <returns></returns>
        public string Script(string mess, string loc)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("<script language='javascript'>");
            sb.Append("alert('");
            sb.Append(mess);
            sb.Append("');");
            sb.Append(loc);
            sb.Append("</script>");
            return sb.ToString();

        }
        /// <summary>
        /// 弹出错误的信息
        /// </summary>
        /// <param name="err"></param>
        public static void ShowErrorstatic(string err)
        {
           // System.Web.HttpContext.Current.Response.Write(DbAccess.Scriptstatic(err, ""));
        }
        /// <summary>
        /// 显示信息
        /// </summary>
        /// <param name="err"></param>
        public static void ShowMessagestatic(string mes, string loc)
        {
            //System.Web.HttpContext.Current.Response.Write(DbAccess.Scriptstatic(mes, loc));
        }
         //<summary>
         //javascript脚本
         //</summary>
         //<param name="mess"></param>
         //<param name="loc"></param>
         //<returns></returns>
        public static string Scriptstatic(string mess, string loc)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("<script language='javascript'>");
            sb.Append("alert('");
            sb.Append(mess);
            sb.Append("');");
            sb.Append(loc);
            sb.Append("</script>");
            return sb.ToString();

        }
        public SqlParameter[] MakeParameters(params string[] pas)
        {
            SqlParameter[] tempPas = new SqlParameter[pas.Length / 2];
            if (pas.Length % 2 == 0)
            {
                for (int i = 0; i < pas.Length / 2; i++)
                {
                    tempPas[i] = new SqlParameter(pas[i * 2], pas[i * 2 + 1]);
                }
            }
            return tempPas;

        }
 
    }
    public class SqlTranModel
    {
        private string _sql;
        public string Sql
        {
            set { this._sql = value; }
            get { return this._sql; }
        }
        private SqlParameter[] _pas;
        public SqlParameter[] Pas
        {
            set { this._pas = value; }
            get { return this._pas; }
        }
    }
}

分享到:
评论

相关推荐

    一个mysql数据库连接类

    这个“一个mysql数据库连接类”就是这样一个工具,它允许开发者更高效、灵活地管理MySQL数据库连接。 首先,我们要理解数据库连接类的概念。在面向对象编程中,类是定义对象特性和行为的模板。在这个特定的场景中,...

    php的mysql数据库连接类

    通过使用这样的数据库连接类,开发者可以更高效、更安全地管理他们的MySQL数据库操作,避免重复编写连接、查询和结果处理的代码。同时,类`db.php`可能还有其他的特性,如日志记录、连接池等,以提升开发效率和系统...

    net的数据库连接类

    本文将深入探讨.NET中的数据库连接类,包括如何创建、管理和关闭数据库连接,以及相关的重要知识点。 首先,数据库连接的核心类是`System.Data.SqlClient.SqlConnection`(对于SQL Server)和`System.Data.OleDb....

    数据库连接类——jdbc

    数据库连接类 支持SQLServer MySql Sybase Oracle

    自己建vb.net 2008下数据库连接类源码-很简单

    vb.net 2008下数据库连接类源码: copy文件到你项目下,然后添加现有项,选择slq_conn.vb,然后添加你的数据库名字、用户名、密码。 在你程序中添加以下代码,即可使用数据库连接了。 里面还定义了一些其他的连接...

    用工厂模式开发多数据库连接类

    在这个“用工厂模式开发多数据库连接类”的实例中,我们将深入探讨如何运用工厂模式来管理多种数据库连接类。 首先,我们要理解数据库连接类的作用。在Java或其他编程语言中,数据库连接类通常用于建立和管理与...

    简单实用的php mysql数据库连接类

    // 假设这就是我们的数据库连接类 $db = new Database('localhost', 'username', 'password', 'database_name'); if (!$db-&gt;connect()) { die('连接失败: ' . $db-&gt;getError()); } // 执行查询 $result = $db-&gt;...

    不平凡的数据库连接类

    数据库连接类是编程中用于与数据库交互的重要组件,它的主要职责是建立、管理和关闭到数据库的连接。在本文中,我们将深入探讨一个不平凡的数据库连接类,它具有两个独特的特性:从资源文件中获取配置信息以及处理...

    数据库连接类数据库连接类

    根据给定的文件信息,我们可以提炼出与数据库连接类相关的几个关键知识点,这些知识点主要围绕着如何在.NET框架中创建和使用数据库连接类,以及如何执行存储过程和SQL语句。 ### 数据库连接类(DBHelper)设计原理 ...

    常用php-mysql数据库连接类.zip

    一个常用php mysql数据库连接类,这是比较基础的东西,能过构造函数来实现创建类就自动与mysql服务器进行连接,只要设置好 $name,$pass,$table三个变量的值就好了。

    DBHelper类+数据库连接类

    DBHelper类+数据库连接类DBHelper类+数据库连接类DBHelper类+数据库连接类DBHelper类+数据库连接类DBHelper类+数据库连接类DBHelper类+数据库连接类DBHelper类+数据库连接类DBHelper类+数据库连接类DBHelper类+...

    c# 数据库连接类

    在C#编程中,数据库连接类是用于与各种数据库系统进行交互的重要工具。这个特定的“c# 数据库连接类”适用于初学者,它能够帮助开发者轻松地建立和管理到不同数据库系统的连接,如Access、SQL Server、Oracle以及...

    比较完整SQl数据库和As数据库连接类

    SQL(Structured Query Language)和AS数据库连接类是两种不同的数据管理方式,它们各有优劣。这里我们将深入探讨SQL数据库和AS数据库连接类,以及如何进行比较。 首先,SQL数据库,全称为结构化查询语言数据库,是...

    php-mysql完整数据库连接类.zip

    一个php-mysql完整数据库连接类,测试阶段,显示所有错误,具有安全隐患,默认关闭 ,发现错误是否立即终止,默认true,建议不启用,因为当有问题时用户什么也看不到是很苦恼的 ,数据库执行语句,可执行查询添加修改...

    数据库连接类DataBase

    数据库连接类`DataBase`是Java编程中用于管理数据库连接的重要组件。在Java应用程序中,数据库交互通常是通过JDBC(Java Database Connectivity)API来实现的。`DataBase`类通常是对JDBC API的一种封装,以简化...

    MySQL数据库连接类

    一个简单的数据库连接类,附有更新,删除等操作。MySQL数据库连接类。

    通用数据库连接类(配置文件)

    本文将详细介绍如何使用提供的“通用数据库连接类(配置文件)”来实现灵活的数据库访问。这个工具类集成了多种常见数据库(如SQLServer、Oracle、MySQL)的支持,使得开发者无需修改源代码,只需调整配置文件即可...

    DBUtility 包含所有的数据库连接类

    首先,我们来看SQL SERVER的数据库连接类。SQL SERVER是微软公司推出的关系型数据库管理系统,广泛应用于企业级应用。它的连接类通常会使用ADO.NET框架,通过`System.Data.SqlClient`命名空间下的`SqlConnection`类...

    数据库连接类JAVA类

    标题中的"数据库连接类JAVA类"指的是一个专门设计用于管理数据库连接的Java类。这样的类通常包含了一系列方法,用于建立、管理和关闭数据库连接,执行SQL查询,以及处理查询结果。在网站开发中,这种类的应用极为...

    c# SQL server数据库连接类

    用于描述与SQL SERVER连接时用到的一些常用函数,可实现大多数操作

Global site tag (gtag.js) - Google Analytics