本文介绍了访问插入语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我习惯了SQL Server,没有Access,但这一件事必须在 Access中完成。你可以根据语法告诉我这个查询是否有效吗? 我正在尝试在数据库中创建一个新行,在一个表中,以及主要的 key是一个名为PersonalID的自动编号。这是在第二页, 显示在个人填写了第一页上的一些信息后,然后 使用POST提交表格。数据库名称为Shape,表名为 Personal。 ----------------------- ------------------------------------------------ DB_CONNECTIONSTRING =" DRIVER = {Microsoft Access Driver(* .mdb)}; DBQ =" &安培; _ Server.Mappath(" Shape.mdb")& "" 设置objRecordset = Server.CreateObject(" ADODB.Recordset") objRecordset.Open" Shape",DB_CONNECTIONSTRING,adOpenStatic , adLockPessimistic,adCmdTable strFirstName = Replace(Trim(Request.Form(" FirstName"))),"''"," '''''") strLastname =替换(修剪(Request.Form(" LastName"))),"''",'''''") strSQL =" set nocount on; INSERT INTO Personal(FirstName,LastName)VALUES (strFirstName,strLastName);选择@@ identity [newid];" 设置rs = objConnection.execute(strSQL) strPersonalID = RS(" newid") rs.Close 解决方案 FYI,它确实如此Jet 4.0 Bob primary key是一个名为PersonalID的自动编号。这是在第二页上,显示在个人填写了第一页上的一些信息之后,然后使用POST提交了表格。数据库名称为Shape,表格为,名为Personal。 --------------------------- -------------------------------------------- DB_CONNECTIONSTRING = DRIVER = {Microsoft Access Driver(* .mdb)}; DBQ =" &安培; _ Server.Mappath(" Shape.mdb")& &;;" 设置objRecordset = Server.CreateObject(" ADODB.Recordset") objRecordset.Open" Shape",DB_CONNECTIONSTRING,adOpenStatic, adLockPessimistic,adCmdTable strFirstName =替换(修剪(Request.Form(" FirstName"))),"''","''''") strLastname =替换(修剪) (Request.Form(" LastName")),"''","''''") strSQL =" set nocount on; INSERT INTO Personal(FirstName,LastName) VALUES I am used to SQL Server, no Access, but this one thing has to be done inAccess. Can you tell me if this query will work, based on the syntax?I am trying create a new row on the database, in one table, and the primarykey is an Autonumber called PersonalID. This is on the second page, whichshows after the personal has filled out some info on the first page, thensubmitted the form using POST. Database name is Shape, and table is namedPersonal.-----------------------------------------------------------------------DB_CONNECTIONSTRING = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & _Server.Mappath("Shape.mdb") & ";"Set objRecordset = Server.CreateObject("ADODB.Recordset")objRecordset.Open "Shape", DB_CONNECTIONSTRING, adOpenStatic,adLockPessimistic, adCmdTablestrFirstName = Replace(Trim(Request.Form("FirstName")),"''","''''")strLastname = Replace(Trim(Request.Form("LastName")),"''","''''")strSQL = "set nocount on; INSERT INTO Personal(FirstName,LastName) VALUES(strFirstName,strLastName); select @@identity [newid];"Set rs=objConnection.execute (strSQL)strPersonalID = RS("newid")rs.Close 解决方案FYI, it does as of Jet 4.0Bob primary VALUES 这篇关于访问插入语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-26 08:33