Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
janevok
Starting Member
1 Post |
Posted - 2008-03-20 : 08:09:20
|
What I am Trying To AchieveI am trying to get the ID of the row I am inserting - using code that works fine on: SQL Server 2000 with an ODBC connection and SQL Server 2005 with an ODBC connectionProblemWhen the code is executed it inserts the row 4 times.My SettingsI have the following OLE DB connection string:-Provider=SQLOLEDB.1;User ID=myuserid;Initial Catalog=dbname;Data Source=dbserveraddress;User Id=myuserid;PASSWORD=mypassword;and I am executing the following SQL:-session("sessionID") = dbExecuteRS("SET NOCOUNT ON;INSERT INTO myTable (ipAddress) VALUES('"& request.serverVariables("REMOTE_HOST") &"');SELECT SCOPE_IDENTITY();SET NOCOUNT OFF;")(0)dbExecuteRS = a function that executes a queryI know my asp page is only executing this sql once but the SQL Profiler says it is running multiple times.What I've Tried So Far1) A normal insert works fine - only inserts one row2) The same SQL with an OLE DB connection string on SQL Server 2000 encounters the same problem - the insert sql with the set nocount on inserts 4 rows3) I've tried using this bit of SQL/ASP which causes the same problem:-set tmpRS = dbExecuteRS("SET NOCOUNT ON;INSERT INTO mytable (ipAddress) VALUES('"& request.serverVariables("REMOTE_HOST") &"');SELECT newID = SCOPE_IDENTITY();")if not tmpRS.eof then response.write("tmpRS('newID'): " & tmpRS("newID") & "<BR>") end ifset tmpRS = nothingConclusionFrom all of my tests I can conclude that this problem ONLY happens when we are connecting to the database via the OLE DB connection string and using an INSERT statement with SET NOCOUNT ONAll ideas/suggestions appreciated, thanks. |
|
rmiao
Master Smack Fu Yak Hacker
7266 Posts |
Posted - 2008-03-21 : 00:12:18
|
Sounds bug, did you report to Microsoft? |
 |
|
|
|
|