HTML表单不在访问数据库中插入数据

时间:2017-03-14 22:47:51

标签: html asp.net ms-access

我想将HTML表单中的数据插入到访问数据库中,但是当我将此insertdata.asp文件调用时,我会收到错误。

<% 
Dim adoCon          
Dim rsAddComments   
Dim strSQL          

Set adoCon = Server.CreateObject("ADODB.Connection")

adoCon.Open "Provider=Microsoft.ACE.OLEDB.12.0;DataSource=J:\John\__Ecommerce_____\ASP\DB_Form\app_data\clients.accdb"

Set rsAddComments = Server.CreateObject("ADODB.Recordset")

strSQL = "SELECT clientname, phone, email, lastservicedate, more-info FROM pelates;"

rsAddComments.CursorType = 2
rsAddComments.LockType = 3    
 rsAddComments.Open strSQL, adoCon   
 rsAddComments.AddNew

 rsAddComments.Fields("clientname") = Request.Form("clientname")
 rsAddComments.Fields("phone") = Request.Form("phone")
 rsAddComments.Fields("email") = Request.Form("email")
rsAddComments.Fields("lastservicedate") = Request.Form("lastservicedate")
rsAddComments.Fields("more-info") = Request.Form("more-info")

rsAddComments.Update

rsAddComments.Close
Set rsAddComments = Nothing
Set adoCon = Nothing


 Response.Redirect "index.asp"


     %>

1 个答案:

答案 0 :(得分:0)

必须将奇怪的字段名括起来:

strSQL = "SELECT clientname, phone, email, lastservicedate, [more-info] FROM pelates;"