【发布时间】:2012-07-13 12:27:40
【问题描述】:
您好,我开发了以下代码来将数据集保存在 Global.asax 文件中。要在webpage.aspx.vb 文件中使用它,现在它工作正常。
同理,如何调用Global.asax中的存储过程?
请帮忙,在此先感谢您!
Shared _cache As Cache = Nothing
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
_cache = Context.Cache
RefreshCache(Nothing, Nothing, 0)
End Sub
Private Shared Sub RefreshCache(ByVal key As String, ByVal item As Object, ByVal reason As CacheItemRemovedReason)
Dim adapter As New SqlDataAdapter("SELECT * FROM dbo.table where logid = 1", "server=server;database=database;uid=userid;pwd=password")
Dim ds As New DataSet()
adapter.Fill(ds, "Quotations")
Dim onRemove As CacheItemRemovedCallback
onRemove = New CacheItemRemovedCallback(AddressOf RefreshCache)
_cache.Insert("Quotes", ds, New CacheDependency("C:\AspNetSql\Quotes.Quotations"), Cache.NoAbsoluteExpiration, Cache.NoSlidingExpiration, CacheItemPriority.[Default], onRemove)
End Sub
【问题讨论】:
-
您可以像在任何代码隐藏文件中调用它一样调用它。你到底有什么问题?
-
我昨天回答了这个问题...read this
-
我理解你们对我说的话,但是我的 global.asax 文件带有 vb.net 代码,它不是写在一个类中以继承任何其他基类,无论如何,谢谢你们,我已经用你的建议解决了这个问题。之前,我想太多要实现下面的答案代码现在我明白了。
标签: vb.net stored-procedures global-asax