asp中添加记录的问题,加了个id自动编号,怎么改
原先就用学号排序,后来因为学号中要添加字母,改成了文本,另加了一个字段id,结果添加不上记录了,该怎样改呢原来代码是可以添加的,原来代码如下:<METAcontent="...
原先就用学号排序,后来因为学号中要添加字母,改成了文本,另加了一个字段id,结果添加不上记录了,该怎样改呢
原来代码是可以添加的,原来代码如下:
<META content="TEXT/HTML;CHARSET=GB2312">
<%@ CODEPAGE="936"%>
<!--#include file="dbconn.asp" -->
<%
dim rs
dim sql
'定义接收数据的临时变量
dim T_S_ID
dim T_S_NAME
dim T_S_SEX
dim T_S_IDCARD
dim T_S_NATIONALITY
dim T_S_BIRTHDAY
dim T_S_ENTRANCE
dim T_S_ACADEMY
dim T_S_CLASS
dim T_S_DIRECTION
dim T_S_DEGREE
dim T_S_RESUME
dim T_S_PHOTO
'接收数据
T_S_ID=request.Form("txtID")
T_S_NAME=request.Form("txtNAME")
T_S_SEX=request.Form("rgSEX")
T_S_IDCARD=request.Form("txtIDCARD")
T_S_NATIONALITY=request.Form("selectNATIONALITY")
T_S_BIRTHDAY=request.Form("txtBIRTHDAY")
T_S_ENTRANCE=request.Form("txtENTRANCE")
T_S_ACADEMY=request.Form("selectACADEMY")
T_S_CLASS=request.Form("selectCLASS")
T_S_DIRECTION=request.Form("selectDIRECTION")
T_S_DEGREE=request.Form("txtDEGREE")
T_S_PHOTO=request.Form("txtPHOTO")
T_S_RESUME=request.Form("txtRESUME")
'查询是否有相同学号的学生信息,若没有则录入
set rs=server.CreateObject("ADODB.RecordSet")
sql="select * from T_STUDENT where T_S_ID="&T_S_ID
rs.open sql,conn,3,2
if rs.eof then
'录入新的学生信息
rs.addnew
rs("T_S_ID")=T_S_ID
rs("T_S_NAME")=T_S_NAME
rs("T_S_SEX")=T_S_SEX
rs("T_S_IDCARD")=T_S_IDCARD
rs("T_S_NATIONALITY")=T_S_NATIONALITY
rs("T_S_BIRTHDAY")=T_S_BIRTHDAY
rs("T_S_ENTRANCE")=T_S_ENTRANCE
rs("T_S_ACADEMY")=T_S_ACADEMY
rs("T_S_CLASS")=T_S_CLASS
rs("T_S_DIRECTION")=T_S_DIRECTION
rs("T_S_DEGREE")=T_S_DEGREE
rs("T_S_PHOTO")=T_S_PHOTO
rs("T_S_RESUME")=T_S_RESUME
rs.update
response.write "成功录入"
else
response.write "已经有相同学号存在!"
end if
rs.close
set rs=nothing
response.redirect "DEFAULT.ASP"
%>
改成1,3还是不好用啊 展开
原来代码是可以添加的,原来代码如下:
<META content="TEXT/HTML;CHARSET=GB2312">
<%@ CODEPAGE="936"%>
<!--#include file="dbconn.asp" -->
<%
dim rs
dim sql
'定义接收数据的临时变量
dim T_S_ID
dim T_S_NAME
dim T_S_SEX
dim T_S_IDCARD
dim T_S_NATIONALITY
dim T_S_BIRTHDAY
dim T_S_ENTRANCE
dim T_S_ACADEMY
dim T_S_CLASS
dim T_S_DIRECTION
dim T_S_DEGREE
dim T_S_RESUME
dim T_S_PHOTO
'接收数据
T_S_ID=request.Form("txtID")
T_S_NAME=request.Form("txtNAME")
T_S_SEX=request.Form("rgSEX")
T_S_IDCARD=request.Form("txtIDCARD")
T_S_NATIONALITY=request.Form("selectNATIONALITY")
T_S_BIRTHDAY=request.Form("txtBIRTHDAY")
T_S_ENTRANCE=request.Form("txtENTRANCE")
T_S_ACADEMY=request.Form("selectACADEMY")
T_S_CLASS=request.Form("selectCLASS")
T_S_DIRECTION=request.Form("selectDIRECTION")
T_S_DEGREE=request.Form("txtDEGREE")
T_S_PHOTO=request.Form("txtPHOTO")
T_S_RESUME=request.Form("txtRESUME")
'查询是否有相同学号的学生信息,若没有则录入
set rs=server.CreateObject("ADODB.RecordSet")
sql="select * from T_STUDENT where T_S_ID="&T_S_ID
rs.open sql,conn,3,2
if rs.eof then
'录入新的学生信息
rs.addnew
rs("T_S_ID")=T_S_ID
rs("T_S_NAME")=T_S_NAME
rs("T_S_SEX")=T_S_SEX
rs("T_S_IDCARD")=T_S_IDCARD
rs("T_S_NATIONALITY")=T_S_NATIONALITY
rs("T_S_BIRTHDAY")=T_S_BIRTHDAY
rs("T_S_ENTRANCE")=T_S_ENTRANCE
rs("T_S_ACADEMY")=T_S_ACADEMY
rs("T_S_CLASS")=T_S_CLASS
rs("T_S_DIRECTION")=T_S_DIRECTION
rs("T_S_DEGREE")=T_S_DEGREE
rs("T_S_PHOTO")=T_S_PHOTO
rs("T_S_RESUME")=T_S_RESUME
rs.update
response.write "成功录入"
else
response.write "已经有相同学号存在!"
end if
rs.close
set rs=nothing
response.redirect "DEFAULT.ASP"
%>
改成1,3还是不好用啊 展开
3个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询