标题:[原创]asp+access改成asp+mssql后发生的问题.请大家帮忙.急!!!!!!!!!!!!谢谢 ...
只看楼主
zhao9110
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2005-5-21
 问题点数:0 回复次数:1 
[原创]asp+access改成asp+mssql后发生的问题.请大家帮忙.急!!!!!!!!!!!!谢谢!

信息输入页面:userreg2.asp ---------------------------------------------------- <%PageName="UserReg2"%> <!--#include file="conn.asp"--> <!--#include file="const.asp"--> <!--#include file="top.asp"--> <!--#include file=function.asp -->

<table cellpadding=0 cellspacing=0 border=0 width=<%=TableWidth%> bgcolor=<%=MainBgColor%> align=center> <FORM name=reg2 action=UserRegPost.asp method=post> <TR> <%=OutTable("left")%> <td align=center> <table border=0 cellpadding=0 cellspacing=0 width=200> <tr> <td><br> <fieldset width=20%> <legend align=center>| 新会员注册 |</legend> <table border=0 cellpadding=0 cellspacing=0 width=400 bgcolor=<%=MainCColor%>> <tr> <TD width=30% align=right>**注册名:</TD> <TD><INPUT maxLength=20 size=16 name=UserName> (可以使用中英文匿名)</TD> </TR> <TR> <TD align=right>**密 码:</TD> <TD><INPUT type=password maxLength=20 size=16 name=password></TD> </TR> <TR> <TD align=right>**密码确认:</TD> <TD><INPUT type=password maxLength=20 size=16 name=password2></TD> </TR> <TR> <TD align=right>**Email地址:</TD> <TD><INPUT size=30 name=Email></TD> </TR> <TR> <TD align=right>性 别:</TD> <TD><INPUT type=radio checkED value="1" name=sex> 男 <INPUT type=radio value="0" name=sex> 女</TD> </TR> <TR> <TD align=right>OICQ号码:</TD> <TD><INPUT size=20 name=OICQ></TD> </TR> <TR> <TD align=right>主页名称:</TD> <TD><INPUT size=30 name=UserWebName></TD> </TR> <TR> <TD align=right>主页地址:</TD> <TD><INPUT size=30 name=UserWebUrl value="http://"></TD> </TR> <TR> <TD align=right>签 名:</TD> <TD><TEXTAREA name=MyIntro rows=5 wrap=PHYSICAL cols=40></TEXTAREA></TD> </TR> <TR align=center> <TD colspan=2 height=30><INPUT value="注 册" name=Submit type=submit> <INPUT type=reset value="重 写" name=Submit2></TD> </TR> </TABLE> </fieldset> </td> </tr> </table> <br> </td> <%=OutTable("right")%> </tr> </FORM> </table> <%set rs=nothing%><!--#include file="copyright.asp"--> ---------------------------------------------------------------------------------- 将输入的数据传到UserRegPost.asp 代码如下: ------------------------------------------------- <%PageName="UserRegPost"%> <!--#include file="conn.asp"--> <!--#include file="const.asp"--> <!--#include file="session.asp"--> <!--#include file="INC/CHAR.INC"--> <!--#include file=function.asp -->

<%

founderr=false

if request.form("UserName")="" or len(request.form("UserName"))>20 then errmsg=errmsg+"<li>用户名输入错误(未输入或长度超过了20个字节)。" founderr=true else UserName=trim(request.form("UserName")) end if if request.form("sex")="" then errmsg=errmsg+"<li>请选择您的性别。" founderr=true elseif left(UserName,3)="%20" OR InStr(UserName,"=")<>0 or InStr(UserName,"`")<>0 or InStr(UserName," ")<>0 or InStr(UserName," ")<>0 or InStr(UserName,"'")<>0 or InStr(UserName,chr(34))<>0 or InStr(UserName,"\")<>0 or InStr(UserName,",")<>0 or InStr(UserName,"<")<>0 or InStr(UserName,">")<>0 or InStr(UserName,"&lt;")<>0 or Instr(UserName,"&gt;") or UserName="大家" or Instr(UserName,"爱雪") or UserName="无" or Instr(UserName,"爸") or Instr(UserName,"妈") or Instr(UserName,"娘") or Instr(UserName,"爷") or Instr(UserName,"奶") or Instr(UserName,"老子") or Instr(UserName,"你") or Instr(UserName,"他") or Instr(UserName,"她") or UserName="站长" or UserName="root" or UserName="administrator" or UserName="admin" or UserName="sex" then errmsg=errmsg+"<li>你输入的帐号非法,可能有非法的字符或字符串。" founderr=true elseif request.form("sex")=0 or request.form("sex")=1 then sex=request.form("sex") else errmsg=errmsg+"<li>您输入的字符非法。" founderr=true end if if request.form("password")="" or Len(request.form("password"))>20 then errmsg=errmsg+"<li>请输入您的密码(长度不能大于20)。" founderr=true else password=request.form("password") end if if password<>request("password2") then errmsg=errmsg+"<li>您输入的密码和确认密码不一致。" founderr=true end if if IsValidEmail(trim(request.form("Email")))=false then errmsg=errmsg+"<li>您的Email有错误。" founderr=true else Email=trim(request.form("Email")) end if

if trim(request.form("UserWebName"))<>"" then if trim(request.form("UserWebUrl"))="" or trim(request.form("UserWebUrl"))="http://" then errmsg=errmsg+"<li>您输入了网站名称,但是没有输入网站地址。" founderr=true end if else if trim(request.form("UserWebUrl"))<>"" or trim(request.form("UserWebUrl"))="http://" then errmsg=errmsg+"<li>您没有输入网站名称,但是您输入了网站地址。" founderr=true end if end if

if founderr=true then call error() else set rs=server.createobject("adodb.recordset") sql="select * FROM Users where username='"&username&"'" rs.open sql,conn,1,3 if not rs.eof or username=WebTitle then errmsg="<br>"+"<li>对不起,您输入的用户名已经被注册,请重新输入。" founderr=true else rs.addnew rs("username")=username rs("password")=password rs("email")=email if request.form("MyIntro")<>"" then rs("sign")=htmlencode2(trim(request.form("MyIntro"))) if request.form("oicq")<>"" then rs("oicq")=request.form("oicq") if request.form("UserWebName")<>"" and request.form("UserWebUrl")<>"" then rs("UserWebName")=request("UserWebName") rs("UserWebUrl")=request("UserWebUrl") end if if RegFree=1 then rs("IsChecked")=1 else rs("IsChecked")=0 end if Rs("sex")=sex Rs("addDate")=now() rs("logins")=0 Rs("lastlogin")=now() rs("UserLevel")=1 rs("UserPoint")=0 rs.update end if rs.close

if founderr=true then call error() else %>

<!--#include file="top.asp"--> <table cellpadding=0 cellspacing=0 border=0 width=<%=TableWidth%> bgcolor=<%=MainBgColor%> align=center> <tr> <%=OutTable("left")%> <td align=center> <br> <table border="1" width="50%" align="center" cellspacing="0" cellpadding="5" class="TableLine" bordercolorlight="<%=MainBColor%>"> <tr > <td colspan=2 align="center" height=24 bgcolor=<%=MainTColor%>><b>会员注册成功</b></td> </tr> <tr> <td width=22% align=right>注 册 名</td> <td width="78%"><%=username%></td> </tr> <tr> <td align=right width="22%">性 别</td> <td width="78%"> <%if sex=1 then%> 男 <%else%> 女 <%end if%> </td> </tr> <tr> <td align=right width="22%">密 码</td> <td width="78%"><%=password%> </td> </tr> <tr> <td align=right width="22%">Email地址</td> <td width="78%"><%=email%> </td> </tr> <tr> <td align=right width="22%">OICQ号码</td> <td width="78%"> <%if request.form("oicq")="" then%> 未填写 <%else%> <%=request.form("oicq")%> <%end if%> </td> </tr> <tr> <td align=right width="22%">主页</td> <td width="78%"> <%if request.form("UserWebUrl")="" or request.form("UserWebName")="" then%> 未填写 <%else%><a href="<%=request.form("UserWebUrl")%>" target=_blank> <%=request.form("UserWebName")%> </a> <%end if%> </td> </tr> <tr> <td align=right width="22%">会员积分</td> <td width="78%">0</td> </tr> <tr> <td align=right width="22%">会员等级</td> <td width="78%"><%=Level(1)%> </td> </tr> <tr> <td align=right valign=top width="22%">签 名</td> <td width="78%"> <%if trim(request.form("MyIntro"))="" then%> 未填写 <%else%> <%=htmlencode2(trim(request.form("MyIntro")))%> <%end if%> </td> </tr> <tr> <td align=center colspan=2><%if RegFree=0 then%>请耐心等待管理员的认证<%else%><a href=UserLogin.asp>请登陆</a><%end if%></td> </tr> </table> <br></td> <%=OutTable("right")%> </tr> </table> <% set rs=nothing %> <!--#include file="copyright.asp"--> <% end if end if %> ------------------------- 通过上面这个页面数据应该写入到mssql数据库中,但是就是不能写入.我认为以下语句有问题 rs.addnew rs("username")=username rs("password")=password rs("email")=email if request.form("MyIntro")<>"" then rs("sign")=htmlencode2(trim(request.form("MyIntro"))) if request.form("oicq")<>"" then rs("oicq")=request.form("oicq") if request.form("UserWebName")<>"" and request.form("UserWebUrl")<>"" then rs("UserWebName")=request("UserWebName") rs("UserWebUrl")=request("UserWebUrl") end if if RegFree=1 then rs("IsChecked")=1 else rs("IsChecked")=0 end if Rs("sex")=sex Rs("addDate")=now() rs("logins")=0 Rs("lastlogin")=now() rs("UserLevel")=1 rs("UserPoint")=0 rs.update end if rs.close ------------------------------------------------------------------ 我应该怎么去做才可以写入数据到mssql数据库?此源码在access数据库下一切正常.请各位帮忙.急!!!!!!!!!!

搜索更多相关主题的帖子: asp mssql access include 
2005-05-21 23:45
zhao9110
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2005-5-21
得分:0 
补充上一贴:
------------------------------------------------
我把access改成mssql后用把自动编号属性改成:标识字段:是,种子:1,递增:1;
并把smalldatetime改成datetime;还有n打头的字段类型的n都去掉.
----------------------------------------------------
请大家帮忙提一下宝贵建议!!!!!!
谢谢!!

2005-05-22 10:09



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-18981-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.661008 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved