1.数据操作类 SqlDBhelper

using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Configuration;
using System.Data;

namespace MessageTool
{
     public class SqlDbhelper
    {
        private SqlConnection conn;
        private SqlCommand cmd;
        private SqlDataReader reader;
        private SqlDataAdapter adapter;
        public  string connectionString = System.Configuration.ConfigurationSettings.AppSettings["connectionstring"];
 
        public string ConnectionString
        {
            get { return this.connectionString; }
            set { this.connectionString = value; }
        }
 
        ///
        /// 获取一个未打开连接的SqlConnection对象
        ///
        /// SqlConnection对象
        public SqlConnection GetConnection()
        {
            if (conn != null)
                return this.conn;
            return this.conn = new SqlConnection(connectionString);
        }
 
        ///
        /// 使用连接字符串获取未打开连接SqlConnection对象
        ///
        /// 连接字符串
        /// SqlConnection对象
        public SqlConnection GetConnection(string _connStr)
        {
            if (this.conn != null)
                this.conn.ConnectionString = _connStr;
   

发布了406 篇原创文章 · 获赞 159 · 访问量 100万+
展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 像素格子 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览