📄 helper.cs
字号:
using System;
using System.Data;
using System.Data.SqlClient;
namespace StudentScroeQuery.DAL
{
/// <summary>
/// 数据访问层的基类
/// </summary>
public class helper
{
public helper()
{
//
// TODO: 在此处添加构造函数逻辑
//
this.comm.Connection=this.conn;
}
protected SqlConnection conn=new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["DbConnectionstring"].ToString());
protected SqlCommand comm=new SqlCommand();
protected SqlDataAdapter ada=new SqlDataAdapter();
//
protected void ExcuteSqlReturnVoid(string sql)
{
this.comm.CommandText=sql;
this.conn.Open();
this.comm.ExecuteNonQuery();
this.conn.Close();
}
//
protected DataSet ExcuteCommandReturnDataSet(SqlCommand comm)
{
comm.Connection=this.conn;
this.ada.SelectCommand=comm;
DataSet ds=new DataSet();
this.ada.Fill(ds);
return ds;
}
//有参数的返回ds
protected DataSet ExcuteCommandReturnDataSetByParameter(SqlCommand comm,int startup,int size,string tablename)
{
comm.Connection=this.conn;
this.ada.SelectCommand=comm;
DataSet ds=new DataSet();
this.ada.Fill(ds,startup,size,tablename);
return ds;
}
//
protected DataSet ExcuteSqlReturnDataSet(string sql)
{
this.comm.CommandText=sql;
this.ada.SelectCommand=this.comm;
DataSet ds=new DataSet();
this.ada.Fill(ds);
return ds;
}
//
protected void ExcuteCommandReturnVoid(SqlCommand cmd)
{
cmd.Connection=this.conn;
this.conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
}
//
protected int ExcuteCommandReturnNumber(SqlCommand cmd)
{
this.conn.Open();
int i=(int)this.comm.ExecuteScalar();
this.conn.Close();
return i;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -