void accessdatasourcel_selected(object sender, sqldatasourcestatuseventargs e) { if (e.exception != null) { if(e.exception.gettype()==typeof(system.data.oledb.oledbexception)) { message.text = "there was a problem opening a connection to the database. please contact the system administrator for this site.";
//optionally set gridviewl.visible = false;
e.exceptionhandled = true; } } }
</script> <html> ...
以下是用vb编写的脚本。
<%@ page language="vb" %> <!doctype html public "-//w3c//dtd xhtml 1.1//en" "http://www.w3.org/tr/xhtmlll/dtd/xhtmlll.dtd">
<script runat="server"> sub accessdatasourcel_selected(byval sender as object, byval e as sqldatasourcestatuseventargs) if (not e.exception is nothing) then if typeof e.exception is system.data.oledb.oledbexception then message. text = "there was a problem opening a connection to the database. please contact the system administrator for this site."
' optionally set gridviewl.visible =false e.exceptionhandled = true end if end if end sub