|
 |
access_asp thread: confirmation of sql statements
Message #1 by "Pieter" <pieter.schockaert@c...> on Wed, 21 Nov 2001 11:08:17
|
|
Hi all,
If I execute the SQL statement:
rs = conn.Execute(sql);
where sql can be an insert, update or delete, how do I know if that action
really is executed? Is there a way to check this (e.g. rs == -1)?
thanks,
Pieter
Message #2 by "Ken Schaefer" <ken@a...> on Thu, 22 Nov 2001 22:29:00 +1100
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "Pieter" <pieter.schockaert@c...>
Subject: [access_asp] confirmation of sql statements
: If I execute the SQL statement:
: rs = conn.Execute(sql);
: where sql can be an insert, update or delete, how do I know if that action
: really is executed? Is there a way to check this (e.g. rs == -1)?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If there is no error...then nothing went wrong. The ADO Connection object
has an Errors collection which contains errors. You can check this for Error
objects if you wish.
You can also check the recordsAffected property - but you can have an UPDATE
statement that works fine, but just doesn't update any rows (because none
match the WHERE clause). This doesn't mean the statement didn't work, it
just means that no records where updated:
Also, when you execute an INSERT, UPDATE or DELETE statement, no records are
returned, so you don't need a recordset.
<%
strSQL = _
"UPDATE table1 " & _
"SET field1 = 'foo' & _
"WHERE field2 = 'bar'"
objConn.Execute strSQL,lngRecsAffected,adCmdText+adExecuteNoRecords
Response.Write(lngRecsAffected & " records where updated.")
%>
Cheers
Ken
|
|
 |