巴西草花梨木价格:注册时,数据库中已有的内容,不能再注册,请问如何编码!

来源:百度文库 编辑:中科新闻网 时间:2024/04/27 11:56:46
比如在注册时,身份证号数据库中已有,不能再注册,提交时会出现提示,请问如何编码!设数据库名为A,表名为B,字段为card_id

看看这个,大概会有帮助,这是一段验证数据库是否有该字段.
dbtype:是我定义的数据库类型
CreateConn:是一个定义的function

if Request.QueryString("card_id")="" then
Response.Write "用户名不能为空。"
else
dim cn,rs
set cn=server.CreateObject("ADODB.Connection")
set rs=server.CreateObject("ADODB.Recordset")
CreateConn cn,dbtype

'=============================存在性验证
rs.Open "SELECT TOP 1 card_id FROM supervisor WHERE card_id='" &Request.QueryString("card_id")& "'",cn,,,1
if not rs.EOF then
Response.Write "身份证号已有,不能再注册。"
else
Response.Write "身份证:" & Request.QueryString("card_id") & "可以使用。"
end if
end if

If not conn.Execute("Select id From [B] where card_id='"&card_id&"'" ).eof Then
session("wrong")="含非法字"
end if

写入资料先,先编写一个查询,查找对比数据库中是否有相同记录。是则返回真,否则返回假,判断真假来决定是否写入新资料