问题描述
我用的是asp.net+access注册按钮触发的代码是:protectedvoidLogin_Click(objectsender,EventArgse){if(Page.IsValid){stringuName=SafeRequest(TextName.Text);stringuPassWd=FormsAuthentication.HashPasswordForStoringInConfigFile(TextPassWd.Text,"MD5").ToString().ToLower().Substring(8,16);stringuEmail=SafeRequest(TextEmail.Text);stringuSex=rblSex.SelectedValue;stringuUrl=SafeRequest(TextUrl.Text);stringuTName=SafeRequest(TextUName.Text);stringuQq=TextQq.Text==""?"0":TextQq.Text;stringuMsn=SafeRequest(TextMsn.Text);stringuAddress=SafeRequest(TextAddress.Text);ExecuteSql("insertinto[Drsky_User](Reg_Name,Reg_PassWd,Email,Sex,User_Url,User_Name,QQ,MSN,Address)values('"+uName+"','"+uPassWd+"','"+uEmail+"','"+uSex+"','"+uUrl+"','"+uTName+"','"+uQq+"','"+uMsn+"','"+uAddress+"')");}}privatevoidExecuteSql(stringp){thrownewException("Themethodoroperationisnotimplemented.");}privatestringSafeRequest(stringp){thrownewException("Themethodoroperationisnotimplemented.");}不添加privatevoidExecuteSql(stringp){thrownewException("Themethodoroperationisnotimplemented.");}privatestringSafeRequest(stringp){thrownewException("Themethodoroperationisnotimplemented.");}这两个的话调试的时候会出现SafeRequestExecuteSql在文中不存在的错误但是加了以后又出现异常点注册就会在这句thrownewException("Themethodoroperationisnotimplemented.");后面提示用户代码未处理Exception请问下这个应该怎么做才是正确的呢?谢谢!
解决方案
解决方案二:
ExecuteSql("insertinto[Drsky_User](Reg_Name,Reg_PassWd,Email,Sex,User_Url,User_Name,QQ,MSN,Address)values('"+uName+"','"+uPassWd+"','"+uEmail+"','"+uSex+"','"+uUrl+"','"+uTName+"','"+uQq+"','"+uMsn+"','"+uAddress+"')");楼主,上面的方法能把数据写进数据库吗?建议自己写一个执行SQL语句方法,返回bool值,最后根据bool判断是否执行成功!