Self-passing ASP.NET (VB.NET) (3) VB.NET exception handling
(1) Structured exception handling :: try ........... Catch ............ flnally ............. And Try in which Catch has three structures: Catch, Catch ... AS and CATCH ... WHEN. Where Catch ... AS and CATCH ... WHEN clause capture specific exceptions and allow the relevant statement block to specify how the application is handled.
Example :( login screen portions of code) Dim sqlconn as New sqlcliet.sqlconnection (configurationsettings.appsettings ( "connectionstring")) Dim select_string as string = "select * from user where user_name = '" & trim (user_name.text) & "' and user_pwd = ' "& trim (user_pwd.text) &"' "Dim select_comm as New sqlclient.sqlcommand (select_string, sqlconn) Dim select_reader as sqlclient.sqldatareader try sqlconn.open () select_reader = selec_comm.executereader (commandbehaviorcloseconnection) if select_reader .read () = True THEN DIM UserName As String Session ("User_name.text) Response.Redirect (" Mian.aspx ") Select_reader.close () sqlconn.close () Else Respo Nse.write ("