set rs=server.createobject("adodb.recordset") '(正确写法) rs.open "select * from dndj",conn,1,3 rs.addnew rs("bh") = bh rs("bm") = bm rs("xm") = xm rs("xsq") = xsq rs.update rs.close set rs=nothing
set rs=server.createobject("adodb.recordset") '(错误写法) sql="insert into dndj(bh,bm,xm,xsq) values('bh','bm','xm','xsq')" rs.open sql,conn,1,3
ACCESS 数据库对应程序的应用:②通过数据源来连接数据库文件
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source="Server.MapPath("database/yanhang.mdb")
这样的数据库连接方式,添加语句:
conn.execute "insert into dndj(bh,bm,xm,xsq) values('"bh"','"bm"','"xm"','"xsq"')" '(正确写法)
set rs=server.createobject("adodb.recordset") '(错误写法) sql="insert into dndj(bh,bm,xm,xsq) values('bh','bm','xm','xsq')" rs.open sql,conn,1,3
三、双引号的应用 通常我们写超级连接这样 a href="abc.asp?id=%=rs("id")%>">超级连接/a> 但要是把这个超级连接编译进asp里面呢
response.write "a href=""abc.asp?id="rs("id")""">超级连接/a>" '(正确写法) response.write "a href='abc.asp?id="rs("id")"'>超级连接/a>" '(正确写法) response.write "a href=abc.asp?id="rs("id")">超级连接/a>" '(正确写法)
response.write "a href="abc.asp?id=%=rs("id")%>">超级连接/a>" '(错误写法) response.write "a href="abc.asp?id="rs("id")"">超级连接/a>" '(错误写法)