我有一个.aspx表单,其中我有一个组合框保存主题我从DB表中检索.
单击提交按钮,在网格视图中查看与该主题相关的问题.
我通过在按钮单击事件中调用函数FillGrid()来实现.
我也有pageindexchanging我的gridview,其中再次调用FillGrid().
在我的FillGrid()函数中,我使用了try catch块.如果发生错误,我想使用Response.Redirect()将页面重定向到错误页面.问题是这个response.redirect无效.其中一个原因是,在按钮点击时,表单会被发布两次.因为在到达response.redirect语句流后返回按钮单击调用FillGrid的地方().
我怎么解决这个问题?或简单地说,如何防止双重发布表单?
我想在发生异常时使用Response.Redirect重定向浏览器.
我还想将异常消息传递给我的错误页面.
例如:
string URL = "Page2.aspx?Exception=" + ex.ToString()
Response.Redirect(URL)
Run Code Online (Sandbox Code Playgroud)
可以吗?这是正确的语法吗?
如果我尝试在sql server 2005中运行以下代码,我会收到错误
BEGIN TRY
SELECT 1/0;
END TRY
BEGIN CATCH
SELECT
ERROR_NUMBER() AS ErrorNumber
,ERROR_SEVERITY() AS ErrorSeverity
,ERROR_STATE() AS ErrorState
,ERROR_PROCEDURE() AS ErrorProcedure
,ERROR_LINE() AS ErrorLine
,ERROR_MESSAGE() AS ErrorMessage;
END CATCH;
GO
Run Code Online (Sandbox Code Playgroud)
错误:
Line 1: Incorrect syntax near 'TRY'.
Msg 156, Level 15, State 1, Line 4
Incorrect syntax near the keyword 'END'.
Msg 195, Level 15, State 10, Line 7
'ERROR_NUMBER' is not a recognized function name.
Run Code Online (Sandbox Code Playgroud)
我正在使用sql server 2000服务管理器,但现在我已经安装了sql server 2005服务管理器,但仍然得到错误..一篇与之相关的文章说
出现此类错误的原因似乎是目标数据库正在MS SQL Server 2000服务器上运行.所以请确保您的数据库服务器是SQL2005
这是什么意思..?我必须做什么改变?