小小问题,来者有分
学了好久的asp.net,却没怎么用过存储过程,大家帮我看一下下面的代码并作一下解释,有些地方不明白啊,我照着视频做都出错,上了年纪,学东西力不从心啊,只能做个人爱好了,大家帮我看看并解释一下,送大分了
public class DataBase
{
private static DataBase _instance;
public DataBase()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
public static DataBase getInstance()
{
if (_instance == null)
{
_instance = new DataBase();
}
return _instance;
}
public static SqlConnection ReturnConn()
{
string strConn = System.Configuration.ConfigurationManager.AppSettings[ "ConnectionString "];
SqlConnection Conn = new SqlConnection(strConn);
if(Conn.State.Equals(ConnectionState.Closed ))
{
Conn.Open();
}
return Conn;
}
public static SqlCommand creatCmd(string procName,SqlParameter [] prams)
{
SqlConnection Conn=ReturnConn();
SqlCommand Cmd = new SqlCommand();
Cmd.CommandType = CommandType.StoredProcedure;
Cmd.Connection = Conn;
Cmd.CommandText = procName;
if (prams != null)
{
foreach(SqlParameter paramenter in prams)
{
if(paramenter !=null)
{