• 大小: 6.37MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-09-25
  • 语言: 其他
  • 标签: MyKTV后台  

资源简介

不错噢 这是MYKTV的后台,可以去参考一下

资源截图

代码片段和文件信息

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

namespace MyKTV
{
    class DBHelper
    {

//@“Data Source=.;Initial Catalog=GoodsManager;Integrated Security=True“
        string connString = @“Data Source=.;Initial Catalog=MyKTV;Integrated Security=True“;
        private SqlConnection conn;

        //创建Connection对象
        public SqlConnection Conn
        {
            get
            {
                if (conn == null)
                {
                    conn = new SqlConnection(connString);
                }
                return conn;
            }
            set { conn = value; }
        }

        //打开连接
        public void OpenConnection()
        {
            if (Conn.State == ConnectionState.Closed)
            {
                Conn.Open();
            }
            else if (Conn.State == ConnectionState.Broken)
            {
                Conn.Close();
                Conn.Open();
            }
        }

        //关闭连接
        public void CloseConnection()
        {
            if (Conn.State == ConnectionState.Open
            || Conn.State == ConnectionState.Broken)
            {
                Conn.Close();
            }
        }

        //执行非查询操作
        public int DbExcuteNoQuery(string sql)
        {
            try
            {
                OpenConnection();
                SqlCommand cmd = new SqlCommand(sqlConn);
                return cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return -1;
            }
            finally
            {
                CloseConnection();
            } 
        }

        //执行查询返回单一结果
        public object DbExcuteScalar(string sql)
        {
            try
            {
                OpenConnection();
                SqlCommand cmd = new SqlCommand(sqlConn);
                return cmd.ExecuteScalar();
             }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
  return null;
            }
            finally
            {
                CloseConnection();
            }    
        }
        
        //执行查询(此连接未关闭请务必用完后手动关闭)
        public SqlDataReader DBSearch(string sql)
        {
            SqlDataReader reader = null;
            try
            {
                OpenConnection();
                SqlCommand cmd = new SqlCommand(sql Conn);
                reader = cmd.ExecuteReader();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            return reader;
        }
    }
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2015-08-09 21:09  后台最终版\
     目录           0  2011-11-25 09:47  后台最终版\KTVDatabase\
     文件     7340032  2014-11-19 13:00  后台最终版\KTVDatabase\MyKTV.mdf
     文件     1048576  2014-11-19 13:00  后台最终版\KTVDatabase\MyKTV_log.ldf
     目录           0  2014-11-18 18:10  后台最终版\MyKTV\
     文件         984  2014-11-10 21:39  后台最终版\MyKTV.sln
     文件       67584  2014-11-18 17:33  后台最终版\MyKTV.v11.suo
     文件       25600  2014-11-11 16:08  后台最终版\MyKTV.v12.suo
     文件         187  2014-11-10 21:39  后台最终版\MyKTV\App.config
     目录           0  2014-11-18 18:10  后台最终版\MyKTV\bin\
     目录           0  2014-11-18 18:10  后台最终版\MyKTV\bin\Debug\
     文件       22714  2014-11-16 16:23  后台最终版\MyKTV\bin\Debug\$this.BackgroundImage.jpg
     文件       93174  2014-11-16 16:14  后台最终版\MyKTV\bin\Debug\$this.Icon.ico
     文件       11776  2014-11-11 14:51  后台最终版\MyKTV\bin\Debug\AxInterop.APlayer3Lib.dll
     文件       17408  2014-11-11 20:16  后台最终版\MyKTV\bin\Debug\AxInterop.MSVidCtlLib.dll
     文件       53760  2014-11-11 20:16  后台最终版\MyKTV\bin\Debug\AxInterop.WMPLib.dll
     文件       13824  2014-11-18 16:58  后台最终版\MyKTV\bin\Debug\Interop.APlayer3Lib.dll
     文件      322560  2014-11-18 16:58  后台最终版\MyKTV\bin\Debug\Interop.MSVidCtlLib.dll
     文件      331264  2014-11-18 16:58  后台最终版\MyKTV\bin\Debug\Interop.WMPLib.dll
     文件     1519616  2014-11-18 17:32  后台最终版\MyKTV\bin\Debug\MyKTV.exe
     文件         187  2014-11-10 21:39  后台最终版\MyKTV\bin\Debug\MyKTV.exe.config
     文件      181760  2014-11-18 17:31  后台最终版\MyKTV\bin\Debug\MyKTV.pdb
     文件       22984  2014-11-18 17:33  后台最终版\MyKTV\bin\Debug\MyKTV.vshost.exe
     文件         187  2014-11-10 21:39  后台最终版\MyKTV\bin\Debug\MyKTV.vshost.exe.config
     文件         490  2012-06-06 02:06  后台最终版\MyKTV\bin\Debug\MyKTV.vshost.exe.manifest
     目录           0  2014-11-10 22:43  后台最终版\MyKTV\bin\Release\
     文件        2928  2014-11-11 16:10  后台最终版\MyKTV\DBHelper.cs
     文件         392  2014-11-16 16:42  后台最终版\MyKTV\frmAbout.cs
     文件        6158  2014-11-16 16:42  后台最终版\MyKTV\frmAbout.Designer.cs
     文件      180122  2014-11-16 16:42  后台最终版\MyKTV\frmAbout.resx
     文件        5395  2014-11-16 16:17  后台最终版\MyKTV\FrmAddSinger.cs
............此处省略76个文件信息

评论

共有 条评论