I’am trying to insert record into db2 table and getting a result with response.write.
My response is Insert OK, but the record isn’t inserted in my table. Here’s the code I use:
<%
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
%>
Any idea on what’s wrong in it?
As an update, my insert is now almost working fine. I say almost, cause i try to insert 4 records in my table, but this code only process the two firsts “insert into” and I don’t understand why.
<%
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
%>
Any idea on what’s wrong in there ?
You can check if any data is inserted into the table with a query like: