再继续请教:数据库读取类是静态方法好还是实例化好?
刚才问了个数据库连接的 现在请教一个读取类的:
如:
namespace BProc
{
public DataSet Re_DataSet(string strProName, ProceducreParameter[] stProParameters)
{
using (B_SqlConn Exsql = new B_SqlConn())
{
DataSet ds = null;
Exsql.Open();
using (SqlCommand Cmd = new SqlCommand(strProName, Exsql.Conn))
{
Cmd.CommandType = CommandType.StoredProcedure;
for (int i = 0; i < stProParameters.Length; ++i)//注意,不是“i++”!
{
ProceducreParameter stProPar = stProParameters[i];
SqlParameter sp = new SqlParameter(stProPar.TabStrName, stProPar.TabStrType, stProPar.TabStrSize);
sp.Direction = stProPar.TabStrDirection;
sp.Value = stProPar.TabStrValue;
Cmd.Parameters.Add(sp);
}
SqlDataAdapter da = new SqlDataAdapter(Cmd);
ds = new DataSet();