我想请教下在窗体设计中,可以通过
try{}
catch(exeception en)
{messagebox.show(en.message)}这种方法来现实库中存储过程提示的错误如(提示已存在相关记录)
if exists(select * from score where xh=@xh and kch=@kch)
raiserror ('已存在相关记录',16,1)
else
if @xh='' or @kch=0 or @cj<0
raiserror ('数据不能为空',16,1)
else
insert into score (xh,kch,cj) values (@xh,@kch,@cj)
那在web中有这样的功能吗?如果有怎么写啊
try{}
catch(exeception en)
{messagebox.show(en.message)}这种方法来现实库中存储过程提示的错误如(提示已存在相关记录)
if exists(select * from score where xh=@xh and kch=@kch)
raiserror ('已存在相关记录',16,1)
else
if @xh='' or @kch=0 or @cj<0
raiserror ('数据不能为空',16,1)
else
insert into score (xh,kch,cj) values (@xh,@kch,@cj)
那在web中有这样的功能吗?如果有怎么写啊
Page.ClientScript.RegisterStartupScript(this.GetType(), "myjs", "alert('"+en.message+"');", true);
这种方法可行,,,一般情况下按钮事件是不是都会引起页面的刷新啊。。(除了用AJAX)
而使用Page.ClientScript.RegisterStartupScript会在输出的html代码当中注册相应的js脚本,避免上述问题