我正在尝试将记录插入 db2 表并使用 response.write 获得结果。我的响应是 Insert OK,但记录没有插入到我的表中。这是我使用的代码:
<%
dim connection
dim sSQL, sConnString
sSQL="INSERT INTO db.tablename (LOGON,CREATION_DATE,CREATOR) VALUES ('logonTest','2012- 06-20-12.00.00.000000','blabla')"
sConnString="data source=blabla;user id=jhonsonjack;password=mypassword"
Set connection = Server.CreateObject("ADODB.Connection")
connection.Open(sConnString)
On Error Resume Next
connection.execute(sSQL)
if Err.number<>0 or connection.Errors.Count <> 0 Then
response.write "Insert Failed"
else
response.write "Insert OK"
end if
On Error Goto 0
Connection.Close
Set Connection = Nothing
%>
知道其中有什么问题吗?
作为更新,我的插入现在几乎可以正常工作了。我说差不多了,因为我尝试在我的表中插入 4 条记录,但是这段代码只处理两个第一个“插入”,我不明白为什么。
<%
dim connection
dim sSQL
dim sConnString
sSQL="INSERT INTO XXXXX.XXXXX(LOGON,CREATION_DATE,CREATOR,ACCOUNT_TYPE,TO_DISABLE,APPLICATION_NAME,ACCOUNT_MODEL,DESCRIPTION,OWNER,FAC_SECURITY,CUPID,REG_FORM,CFIRM_DATE,TO_DELETE,DOCLINK) VALUES ('XXXXX','XXXXX','XXXXX','XXXXX','0','XXXXX','4','XXXXX','XXXXX','XXXXX','XXXXX','0','XXXXX','','XXXXX');INSERT INTO XXXXX.XXXXX (LOGON,CREATION_DATE,CREATOR,ACCOUNT_TYPE,TO_DISABLE,APPLICATION_NAME,ACCOUNT_MODEL,DESCRIPTION,OWNER,FAC_SECURITY,CUPID,REG_FORM,CFIRM_DATE,TO_DELETE,DOCLINK) VALUES ('XXXXX','XXXXX','XXXXX','XXXXX','0','XXXXX','4','XXXXX','XXXXX','XXXXX','XXXXX','0','XXXXX','','XXXXX');INSERT INTO XXXXX.XXXXX (LOGON,CREATION_DATE,CREATOR,ACCOUNT_TYPE,TO_DISABLE,APPLICATION_NAME,ACCOUNT_MODEL,DESCRIPTION,OWNER,FAC_SECURITY,CUPID,REG_FORM,CFIRM_DATE,TO_DELETE,DOCLINK) VALUES ('XXXXX','XXXXX','XXXXX','XXXXX','0','XXXXX','4','XXXXX','XXXXX','XXXXX','XXXXX','0','XXXXX','','XXXXX');INSERT INTO XXXXX.XXXXX (LOGON,CREATION_DATE,CREATOR,ACCOUNT_TYPE,TO_DISABLE,APPLICATION_NAME,ACCOUNT_MODEL,DESCRIPTION,OWNER,FAC_SECURITY,CUPID,REG_FORM,CFIRM_DATE,TO_DELETE,DOCLINK) VALUES ('XXXXX','XXXXX','XXXXX','XXXXX','0','XXXXX','4','XXXXX','XXXXX','XXXXX','XXXXX','0','XXXXX','','XXXXX');"
sConnString="data source=XXXXX;user id=XXXXX;password=XXXXXXXXXX"
Set connection = Server.CreateObject("ADODB.Connection")
connection.Open(sConnString)
set rs = connection.execute(sSQL)
if Err.number<>0 or connection.Errors.Count <> 0 Then
response.write "Insert Failed"
else
response.write "Insert OK" %><br><% response.write sSQL
end if
Connection.Close
%>
知道那里有什么问题吗?