Re: One Insert statement, no looping, creates 2 records?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Steve Kass (skass_at_drew.edu)
Date: 07/20/04


Date: Tue, 20 Jul 2004 08:54:08 -0400

Is there any chance a distributed query is involved? In some
circumstances, you can see this when the first execution generates the
metadata, and the second retrieves the results. This quote is from
http://www.microsoft.com/technet/prodtechnol/sql/2000/maintain/sqlole.mspx:

If *IDBSchemaRowset* is not supported with TABLES, COLUMNS, and
TABLES_INFO rowsets, SQL Server opens the rowset against the base table
twice: once during query compilation to retrieve meta data, and once
during query execution. Providers that incur side effects from opening
the rowset (for example, run code that alters the state of a real-time
device, send e-mail, run arbitrary user-supplied code) must be aware of
this behavior.

Steve Kass
Drew University

EPPack wrote:

>Relatively new to SQL Server 2K. Have an .asp web page where I collect info
>from a simple form, pass it to a 2nd .asp via standard request variables,
>and insert a record into a table. I have a debug-type response.write display
>showing the actual insert code (to assist with syntax issues) right after
>the record gets created, and the record gets created uneventfully except for
>one minor issue. It's inserted twice most of the time! The auto-generated
>key increments, but the rest of the record is definitely identical. What's
>REALLY odd, tho, is that the debug display only shows once, even tho it's
>directly (before or) after the cn.execute statement, and the program is
>straight line, it does not loop. There is only one insert statement in the
>entire program. All objects are correctly named and closed and used with the
>correct set of statements. An email is built and sent in the program
>directly after the record is created, and IT gets sent twice too, even tho,
>again, only one debug message there shows up.
>
>I'm at a loss to figger out how something like this could even be happening.
>I've done LOTS of programs like this, but this is the first one that's done
>this, so I'm not even sure what to look for. I've put in displays, stepped
>it thru with displays, etc etc, but nothing seems to be triggering that 2nd
>write and email.Something MUST be, tho, 'cause the 2nd record and email are
>definitely there. Since the program isn't looping, and the debug display
>only comes out once, it almost seems like there may be something in the db
>or table itself (or the server?) that might be causing duplication, but I
>have no idea what to even look for :( Doesn't explain the double email tho
>:( It looks just as if the program is executing twice, as far as the Insert
>statement and the email is concerned, but only once for the display
>statements. Weird.
>
>I would appreciate any ideas.
>
>
>



Relevant Pages

  • Re: Finally which ORM tool?
    ... Also, if you pass a variable to the query, the value the ... you have a linq query and by changing the variable's value, ... q is affected if I change foo AFTER this query and BEFORE execution. ... And it is a declaration, but one which captures the variables. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Finally which ORM tool?
    ... the session' method. ... able to execute the query by itself. ... has at EXECUTION time is used, ... That SHOULDN'T be important, simply because q LOOKS like a declaration, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Execution plan
    ... I have 191276 rows in table transportOrder, ... index on transportOrder for your query. ... But as you see from query plan, optimizer didn't use this index at ... Sometimes you have query which executes slow(no matter which execution ...
    (microsoft.public.sqlserver.programming)
  • Re: Finally which ORM tool?
    ... the session' method. ... they use the same mechanism as Linq to Sql does: ... Also, if you pass a variable to the query, the value the variable ... q is affected if I change foo AFTER this query and BEFORE execution. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Coworker modified base query, now form does not allow access to query.
    ... Do you have a backup copy of the database? ... Yes, we do, but what I wound up doing was createing a new form via the ... to test out the query. ... its still mildly bugging me about that form, tho... ...
    (microsoft.public.access.forms)