访问数据库asp中的连接字符串错误

时间:2011-08-18 08:29:07

标签: asp-classic

我创建了一个asp反馈网页,此页面与访问数据库连接 当我运行这个页面时,每个东西都没问题,直到我点击提交按钮 当我点击提交按钮时,它会出现错误,如

这是我的asp代码

<%   
DIM objConn
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.ConnectionString =Provider=Microsoft.Jet.OLEDB.4.0;
 Data Source="Server.MapPath("/MyData.mdb")

objConn.Open
%>
<%
DIM objRS
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Open "tblContact",objConn,adLockOptimistic,adCmdTable
objRS.AddNew
objRS("Email") = Request.Form("Email")
objRS("FirstName") = Request.Form("FirstName")
objRS("LastName") = Request.Form("LastName")
objRS("Comments") = Request.Form("Comments")
objRS("DateContacted") = Date()
objRS.Update
%>

<%
DIM strFirstName
strFirstName = Request.Form("FirstName")
%>

<%
objRS.Close
Set objRS = Nothing
objCONN.Close
Set objCONN = Nothing
%> 

1 个答案:

答案 0 :(得分:0)

更新

objConn.ConnectionString =Provider=Microsoft.Jet.OLEDB.4.0;
 Data Source="Server.MapPath("/MyData.mdb")

objConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("/MyData.mdb")