RentHouseDAL/DBHelper.cs

(开头部分) 4KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

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

namespace RentHouseDAL
{
    public static class DBHelper
    {
        public static SqlConnection connection;

        //打开连接
        public static SqlConnection Connection
        {
            get
            {
                if (connection == null)
                {
                    string connString = ConfigurationManager.ConnectionStrings["ConnString"].ConnectionString;
                    connection = new SqlConnection(connString);
                    connection.Open();
                }
                else if (connection.State == ConnectionState.Closed)
                {
                    connection.Open();
                }
                else if (connection.State == ConnectionState.Broken)
                {
                    connection.Close();
                    connection.Open();
                }
                return connection;
            }
        }

        /// <summary>
        /// 执行增,删,改,的方法
        /// </summary>
        /// <param name="commandText">sql,proc</param>
        /// <param name="commandType">CommandType</param>
        /// <param name="para"></param>
        /// <returns>int</returns>             
        public static int ExecuteCommand(string commandText, CommandType commandType, SqlParameter[] para)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = Connection;
            cmd.CommandText = commandText;
            cmd.CommandType = commandType;
            try
            {
                if (para != null)
                {
                    cmd.Parameters.AddRange(para);
                }
                return cmd.ExecuteNonQuery();
            }

后面还有 81 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。