set rs=server.createobject("adodb.recordset") set rs1=server.createobject("adodb.recordset") conn = "DBQ=" + server.mappath("mydb.mdb") + ";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};" sql="select * from mytable where username='"&username&"'" rs.Open sql,conn,1,1 if rs.EOF or rs.bof then sql="insert into mytable(username,sex,borndate,phone,BP,policy,address,company,email) values('"&username&"','"&sex&"','"&borndate&"','"&phone&"','"&BP&"','"&policy&"','"&address&"','"&company&"','"&email&"')" rs1.Open sql,conn,1,3 response.write "<script language=JavaScript>" & chr(13) & "alert('同学信息添加成功!');"&"window.location.href = 'index.asp'"&" </script>" set rs1=nothing else response.write "<script language=JavaScript>" & chr(13) & "alert('此同学早已添加!');" & "history.back()" & "</script>" end if rs.Close set rs=nothing
[Microsoft][ODBC Microsoft Access Driver] 操作必须使用一个可更新的查询。