只为成功找方向,不为失败找借口

每天都不能停止前进的脚步
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

检索参数信息并填充指定的 SqlCommand 对象的 Parameters 集合

Posted on 2011-09-21 17:46  冰碟  阅读(230)  评论(0)    收藏  举报
        private SqlParameterCollection GetSpParameters(string spName)
        {
            SqlCommand myCommand = new SqlCommand();
            myCommand.CommandText = spName;
            myCommand.CommandType = CommandType.StoredProcedure;
            
            myCommand.Connection = new SqlConnection("user id=sa;password=sa;data source=.;persist security info=True;initial catalog=数据库");
            myCommand.Connection.Open();

            SqlCommandBuilder.DeriveParameters(myCommand);

            return myCommand.Parameters;
        }