您现在的位置: 无忧电子商务网 >> 信息学院 >> 程序开发 >> asp >> 正文

处理Asp中的错误

作者:作者:As…    信息学院来源:网络收集    点击数:    更新时间:2006-8-27 我要参与讨论

       处理Asp中的错误
  
  You just finished your ASP application in time, barely making the dealine! As you upload the final version to the webserver, you receive an email from your supervisor indicating that he''s ready for your demo. You confidently stride into his office and give him instructions on accesses the application through the Intranet.
  
  Your boss comes to the first page, and is asked to enter his name. You''ve created a slick, customized feel to the site, recording the user and his or her preferences in a database. Your boss types in his name, "The Pointy Haired Boss," and hits the submit button. Instead of being taken to the next page, he sees the following text pop up on the screen:
  
  Microsoft OLE DB Provider for ODBC Drivers error '' 80004005'' [Microsoft][ODBC Access 97 ODBC driver Driver] syntax wrong near ''
  
  Please note that I just made this error message up, so, please, no emails asking about how one gets this error by entering his name!
  
  You get one of those looks from your boss, a look that says, "I hope you weren''t expecting a positive performance review."
  
  There''s nothing worse to an end user than to see those dreaded ADO errors. They are misformatted, cryptic, and leave the user wondering what they are suppose to do. Your average end user doesn''t know ODBC from OLE. So how can you prevent these nasty error messages?
  
  First you must insert at the top of your ASP page:
  
  
  <% On Error Resume Next %>
  This will tell ASP to just skip over any errors, instead of halting execution and printing out a nasty error message. You may be tempted to leave it at this, although if you do, and errors occur, your users won''t be aware of them. They will think their information was correctly saved, when in actuality it wasn''t due to an ADO error.
  
  What, then, do we want to do if there is an error? Well, the idea situation would be to let the end user know that an error had occurred and will be worked on, and automatically email technical support with the ADO error messages. So that is what we will do!
  
  The question now is how to we "trap" errors? Well, after any ADO call that accesses the database, we will want to put the following lines:
  
  
  
  If Err.number <> 0 then
   TrapError Err.description
  End If
  
  You will want to put this after all ADO calls that communicate directly with the database. This includes ConnectionObject.Open, ConnectionObject.Execute, and RecordsetObj

[1] [2] [3] 下一页

在google里搜索更多处理Asp中的错误

Google
Web www.51ec.org
【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
我来说两句 对此文章发表了评论
  昵 称: *必填    ·注册用户·
  评 分: 1分 2分 3分 4分 5分     严禁发表危害国家安全、政治、黄色淫秽等内容的评论,用户需对自己在使用本网站服务过程中的行为承担法律责任。本站管理员有权保留或删除评论内容,评论内容只代表机友个人观点,与本网站立场无关。  
评 论
内 容

 
评论列表 (最新 评论仅限网友观点!)

供求信息




| 设为首页 | 加入收藏 | 关于我们 | 广告服务 | 联系方式 | 友情链接 | 版权申明