- 爱易网页
-
ASP.NET教程
- [50分两问]关于.net中的存储过程有关问题
日期:2014-05-18 浏览次数:20386 次
[50分两问]关于.net中的存储过程问题
这几天看了下SqlHelper,再加上初学,于是乎手写了一个,有几点疑问:
(环境:vs2008 beta2+sql server 2005)
先贴代码:
sqlhelp.cs文件
public class SqlHelper
{
private SqlConnection Connection;
private string connectionString;
public string ConnectionString
{
get { return connectionString; }
set { connectionString = value; }
}
private CommandType _CommandType;
public CommandType CommandType
{
get{return _CommandType;}
set{_CommandType=value;}
}
public SqlHelper()
{
connectionString = ConfigurationManager.ConnectionStrings[ "connectionString "].ConnectionString;
Connection = new SqlConnection(connectionString);
}
/// <summary>
/// 构造函数(初始化SqlConnection)
/// </summary>
/// <param name= "connectionString "> </param>
public SqlHelper(string connectionString)
{
this.Connection = new SqlConnection(connectionString);
this.CommandType=CommandType.Text;
}
/// <summary>
/// 初始化SqlCommand对象
/// </summary>
/// <param name= "commandText "> T-Sql语句 </param>
/// <returns> SqlCommand对象 </returns>
private SqlCommand BuildInitCommand(string commandText)
{
SqlCommand Command = new SqlCommand(commandText, Connection);
Command.CommandType = this._CommandType;
return Command;
}
/// <summary>
/// 初始化SqlCommand对象
/// </summary>
/// <param name= "commandText "> T-Sql语句 </param>
/// <param name= "op "> SqlParameter数组 </param>
/// <returns> SqlCommand对象 </returns>