2、数据库帮助类

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

namespace SQLServerDAL
{
     public abstract class SqlHelper
    {

       public static readonly string ConnectionStringLocalTransaction =ConfigurationManager.ConnectionStrings["SQLConnectionStirng"].ConnectionString;

         public static SqlDataReader Exefdn(string scon, CommandType ctype, string SQL,SqlParameter param)
         { 
             SqlCommand cm = new SqlCommand();
             SqlConnection con = new SqlConnection(scon);
             try
             {
              
                 if (con.State != ConnectionState.Open)
                 {
                     con.Open();
                 }
                 cm.Connection = con;
                 cm.CommandText = SQL;               
                 cm.CommandType = ctype;
              

                 if (param != null)
                 {                   
                     cm.Parameters.Add(param);
                   
                 }
                 SqlDataReader dr = cm.ExecuteReader(CommandBehavior.CloseConnection);
                 cm.Parameters.Clear();
                 return dr;

             }
             catch (Exception)
             {
                 con.Close();
                 throw;
             }
         }
    }
}

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-17
  • 2022-12-23
猜你喜欢
  • 2021-12-10
  • 2022-02-01
  • 2021-06-13
  • 2022-02-07
  • 2022-01-04
  • 2021-11-25
  • 2021-08-25
相关资源
相似解决方案