zoukankan      html  css  js  c++  java
  • SqlDbHelper的封装

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using Model;
    using System.Data;
    using System.Data.SqlClient;
    using System.Configuration;
    
    namespace DAL
    {
        public class DBHelper
        {
    
           // static string str = ConfigurationManager.ConnectionStrings["conn"].ConnectionString;
    
            SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=four;Integrated Security=True");
    
            //增删改
            public int ExeNonQuery(string sql)
            { 
                //打开数据库
                conn.Open();
                SqlCommand cmd = new SqlCommand(sql,conn);
                int i = cmd.ExecuteNonQuery();
                conn.Close();
                return i;
            }
    
            //聚合函数查询
            public object ExeScalar(string sql)
            {
                conn.Open();
                SqlCommand cmd = new SqlCommand(sql, conn);
                object i = cmd.ExecuteScalar();
                conn.Close();
                return i;  
            }
    
            //多条数据
            public DataTable GetTable(string sql)
            {
                SqlDataAdapter sda = new SqlDataAdapter(sql, conn);
                DataTable dt = new DataTable();
                sda.Fill(dt);
                return dt;
            
            }
    
    
        }
    }
  • 相关阅读:
    jsp登录显示
    flask 分页
    module pip has no attribute main
    html active属性
    Centos7配置
    python爬虫笔记----4.Selenium库(自动化库)
    python爬虫笔记
    python报错记录
    mybatis逆向文件
    python简单验证码
  • 原文地址:https://www.cnblogs.com/gbb44/p/10639110.html
Copyright © 2011-2022 走看看