日期:2014-05-17  浏览次数:20797 次

asp不能更新ACCESS
<%
dbpath   = "data.mdb "
connstr   = "driver={Microsoft   Access   Driver   (*.mdb)};pwd=hardwarewto;dbq= "   &   Server.MapPath( " "&dbpath& " ")

Set   conn   =   Server.CreateObject( "ADODB.Connection ")
conn.open   connstr

set   res=Server.CreateObject( "ADODB.Recordset ")
  sqlcmd= "select   *   from   admin "  
  res.Open   sqlcmd,conn,1,3

  res.addnew
  res( "admin ")= "test "
  res.update
  set   res   =   nothing
response.end  
%>
可是ACCESS并没有增加一条记录?哪里没写好呢?

------解决方案--------------------
改成这样试试:

dbpath = "data.mdb "
connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & Server.MapPath(dbpath)

Set conn = Server.CreateObject( "ADODB.Connection ")
conn.open connstr

------解决方案--------------------
res.Open sqlcmd,conn,1,3
改为
rec.open sqlcmd,conn,3,2