asp.net用储存过程名为参数的DBHelper类(增删改查)
using System;
using System.Collections.Generic;
using System.Text;
using MyHRAdmin.Model;
using System.Data;
using System.Data.SqlClient;
namespace MyHRAdmin.DAL
{
public class DBHelper
{
private static SqlConnection connection;
public static SqlConnection Connection
{
get
{
string con = "Data Source=.;Initial Catalog=HRAdmin;Integrated Security=True";
if (connection == null)
{
connection = new SqlConnection(con);
connection.Open();
}
else if (connection.State == System.Data.ConnectionState.Closed)
{
connection.Open();
}
else if (connection.State == System.Data.ConnectionState.Broken)
{
connection.Close();
connection.Open();
}
return connection;
}
}
//通过sql,存储参数获取reader,判断是否存在(登录)
/// <summary>
/// 重要的
/// </summary>
/// <param name="sqName"></param>
/// <param name="value"></param>
/// <returns></returns>
public static SqlDataReader GetReader(string sqName,params SqlParameter[] value)
{
SqlCommand com = new SqlCommand(sqName,Connection);
com.Parameters.AddRange(value);
com.CommandText = sqName;
com.CommandType = Co
相关新闻>>
- 发表评论
-
- 最新评论 更多>>