学海无涯

记录我的程序人生...

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

public DataSet GetSingleQueryList(string condition)
  {
   SqlParameter[] parameters={ new SqlParameter("@condition1",SqlDbType.NVarChar,50),
new SqlParameter("@condition2",SqlDbType.NVarChar,50)};
   parameters[0].Value=condition1;
                            parameters[1].Value=condition2;

   return RunProcedure("sp_Single_Query",parameters,"EnterpriseRegister");

  }


private SqlCommand BuildQueryCommand(string storedProcName, IDataParameter[] parameters)
  {
   SqlCommand command = new SqlCommand( storedProcName, conn );
   command.CommandType = CommandType.StoredProcedure;

   foreach (SqlParameter parameter in parameters)
   {
    command.Parameters.Add( parameter );
   }

   return command;

  }

  public DataSet RunProcedure(string storedProcName, IDataParameter[] parameters, string tableName )
  {
   conn = new SqlConnection(EnterpriseConn);
   DataSet dataSet = new DataSet();
   conn.Open();
   SqlDataAdapter sqlDA = new SqlDataAdapter();
   sqlDA.SelectCommand = BuildQueryCommand( storedProcName, parameters );
   sqlDA.Fill( dataSet, tableName );
   conn.Close();

   return dataSet;
  }

http://www.microsoft.com/china/community/Column/78.mspx

posted on 2004-06-11 13:11  josson  阅读(674)  评论(0编辑  收藏  举报