DBConnection.cs 1.1 KB
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using System.Data.SqlClient;
using Weld;
namespace Weld
{
    internal class DBConnection
    {

        public static string DBConnstring = Properties.Settings.Default.DBConnectString;

        public static SqlConnection DBConnectionOpen()
        {
            try
            {
                SqlConnection conn = new SqlConnection (DBConnstring);
                conn.Open();
                return conn;
            }
            catch (Exception ex)
            {
                LogExecute.WriteExceptionLog("打开数据库连接", ex);
            }
            return null;
        }
        public static SqlTransaction DBTransOpen(SqlConnection Conn)
        {
            try
            {
                if (Conn != null)
                {
                    return Conn.BeginTransaction();
                }
            }
            catch (Exception ex)
            {
                LogExecute.WriteExceptionLog("开启数据库事务", ex);
            }
            return null;
        }

    }



}