string strConn = "server=.;database=test;uid=sa";
   string strSQL = "insert into person (Name,Age) values (@Name,@Age)";

    //存储参数缓存

   SqlParameter[] paramsToStore = new SqlParameter[2];
   paramsToStore[0] = new SqlParameter("@Name", SqlDbType.VarChar,10);
   paramsToStore[1] = new SqlParameter("@Age", SqlDbType.Int);

   Microsoft.ApplicationBlocks.Data.SqlHelperParameterCache.CacheParameterSet(strConn,strSQL,paramsToStore);


    //获取参数缓存
   SqlParameter[] storedParams = new SqlParameter[2];
   storedParams = SqlHelperParameterCache.GetCachedParameterSet(strConn,strSQL);

   storedParams[0].Value = this.txtName.Text;
   storedParams[1].Value = this.txtAge.Text;


    //执行插入
   SqlHelper.ExecuteNonQuery(strConn,CommandType.Text,strSQL,storedParams);

例子:
Data Access Application Block  参数缓存的使用方法

相关文章: