Note that there are some explanatory texts on larger screens.

plurals
  1. POUnable to insert record from stored procedure called from web service
    primarykey
    data
    text
    <p>I have the following table:</p> <pre><code>CREATE TABLE [dbo].[omgbbq]( [tbl_key] [int] IDENTITY(1,1) NOT NULL, [name] [varchar](10) NOT NULL, [id] [int] NULL, CONSTRAINT [PK_omgbbq] PRIMARY KEY CLUSTERED ( [tbl_key] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] </code></pre> <p>...and the following stored procedure:</p> <pre><code>CREATE PROCEDURE sp_omgwth @name VARCHAR(10), @id INT AS BEGIN INSERT INTO omgbbq (name, id) VALUES (@name, @id); SELECT MAX(tbl_key) AS Max_tbl_key FROM omgbbq; END </code></pre> <p>I added a single record by calling the procedure from SSMS:</p> <pre><code>EXEC sp_omgwth 'Gareth', 2 </code></pre> <p>and get </p> <pre><code>tbl_key,name,id 1,Gareth,2 </code></pre> <p>So far, so good. A colleague tries to call it from a web service and gets the return 'Max_tbl_key' 2</p> <p>Also as expected. However, the record does not appear in the table. When I add a new record by calling the SP from SSMS, we see the following in the table:</p> <pre><code>tbl_key,name,id 1,Gareth,2 3,Gawain,4 </code></pre> <p>It's like it added the record, which incremented the identity value, but then...I don't know, rolled it back or something.</p> <p>Any ideas? Both of us are connecting to the server as the same user, so it doesn't seem like it could be a credential permissions issue. We are getting this same behavior from another table and another SP, which is why we created these two as tests.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload