Sp_OADestory 不清除/销毁创建的对象 [英] Sp_OADestory is not clearing/destroying created object

查看:41
本文介绍了Sp_OADestory 不清除/销毁创建的对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 sp_oacreate 调用网络服务.webservice 只是输出一个从数据库查询的字符串.顺序如下:

I am using sp_oacreate to call a webservice. The webservice just outputs a string queried from a database. Here's the sequence:

  • sp_oacreate -> 创建 MSXML2.XMLHTTP 的实例
  • sp_oamethod -> 打开连接
  • sp_omethid -> 发送
  • sp_oamethod -> 获取响应文本
  • sp_oadestory -> 释放创建对象的内存

我尝试更改数据库中的数据以检查更改是否在 webservice 调用期间得到反映,但输出始终与第一次运行相同.似乎 sp_oadestroy 并不能真正释放内存,或者似乎正在使用缓存.内存问题?

I tried to change the data in the database to check if changes are reflected during webservice call, but the output is always the same from the first run. It seems that sp_oadestroy wasn't really able to free the memory or seems like it's using a cache. Memory issue?

详细说明,这是一个示例运行和/我们的输出:

To elaborate, here's a sample run and/our output:

  • 更新数据库:1,2,3,4
  • 第一次运行输出:1,2,3,4
  • 更新数据库:1,2,3,4,5
  • 第二次运行输出:1,2,3,4
  • .... 以同样的输出

我知道 CLR 最适合这个,但 CLR 在 SQL2000 中不可用,所以它不是替代品.假设我真的必须在 SQL2000 中执行此操作.修补程序或补丁?假设管理员不会允许或冒险(对此没有进一步的问题:D)

I know CLR is best for this but CLR is not available in SQL2000, so it's not an alternative. And let's say I really have to do this in SQL2000. Hotfix or patches? Let's say, administrators won't allow or risk (no further questions on this :D)

请说明这个问题.非常感谢!

Please shed some light over this issue. Thanks a lot!

这是代码的一部分:

SET @url = 'http://url_showtext.php?val1=1&val2=2'
EXEC sp_OACreate 'MSXML2.XMLHTTP', @object OUT
EXEC sp_OAMethod @object, 'open', NULL,'get', @url, 'false'
EXEC sp_OAMethod @object, 'send'
EXEC sp_OAMethod @object, 'responseText', @ResponseText OUTPUT
EXEC sp_OADestroy @object
select @ResponseText 

顺便说一句,请不要问或嘲笑我为什么使用 sp_oacreate 并通过 sql 调用这个 web 服务.我见过很多这样的东西,它们并没有帮助我们切入正题,真的.谢谢!

And just a note by the way, please don't ask or ridicule much on why I'm using sp_oacreate and call this webservice thing via sql please. I've seen much of such and they are not helping to get to the point, really. Thanks!

推荐答案

如果其他人偶然发现这个问题,我将不得不回答我自己的问题:

I'll have to answer my own question in case others stumble upon this issue:

在网页的上半部分添加no-cache"语句即可.就我而言,sp_oamethod 只是调用了一个简单的 asp 经典页面.

Just add "no-cache" statement on the upper part of the webpage. In my case, sp_oamethod just called a simple asp classic page.

所以,只需在asp页面中添加:

So, just add in the asp page:

Response.Expires = 0
Response.Expiresabsolute = Now() - 1
Response.AddHeader "pragma","no-cache"
Response.AddHeader "cache-control","private"
Response.CacheControl = "no-cache" 

这篇关于Sp_OADestory 不清除/销毁创建的对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆