向数据库添加数据!
<%
xm=trim(session("xm"))
xh=trim(session("xh"))
sp=trim(session("sp"))
pj=trim(session("pj"))
set conn=Server.CreateObject("ADODB.Connection")
strProvider="Driver={Microsoft Access Driver(*.mdb)};DBQ="&_Server.MapPath("\")&"\person.mdb;User ID=;Password=; "
conn.open strProvider
Commandtext="Select*from student where no='"&xh&"'"
conn.Execute commandtext,recordsAffected,adcmdtext
if recordsAffected=0 then
Commandtext="Insert into student(no,name,sport,pj) values('"&xh&"','"&xm&"','"&sp&"','"pj"')"
conn.Execute commandtext,recordsAffected,adcmdtext
response.write"已添加到数据库中!"
else
response.write"对不起!你提交的数据有误!"
end if
set conn=nothing
%>
显示的错误是:错误类型:
Microsoft VBScript 编译器错误 (0x800A0408)
无效字符
/ASP/15.asp, line 8, column 60
strProvider="Driver={Microsoft Access Driver(*.mdb)};DBQ="&_Server.MapPath("\")&"\person.mdb;User ID=;Password=; "