473,386 Members | 1,609 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Getting Identity Back

The following insert stored procedure was generated by the 2.0 tableadapter
wizard (I have applied the latest service pack to vs2005)
IF EXISTS (SELECT * FROM sysobjects WHERE name = 'NewInsertCommand' AND
user_name(uid) = 'dbo')
DROP PROCEDURE dbo.NewInsertCommand
GO

CREATE PROCEDURE dbo.NewInsertCommand
(
@FranchiseID nvarchar(16),
@PrimaryVendorID int,
@Status nvarchar(15),
@DateEntered datetime,
@Customer nvarchar(50)
)
AS
SET NOCOUNT OFF;
INSERT INTO [Order] ([FranchiseID], [PrimaryVendorID], [Status],
[DateEntered], [Customer]) VALUES (@FranchiseID, @PrimaryVendorID, @Status,
@DateEntered, @Customer);

SELECT FranchiseID, PrimaryVendorID, Status, DateEntered, Customer, OrderID
FROM [Order] WHERE (OrderID = SCOPE_IDENTITY())
GO

If I execute this SP in SQL Server Management Studio it returns zero
USE [mydb]
GO

DECLARE @return_value int

EXEC @return_value = [dbo].[NewInsertCommand]
@FranchiseID = N'19930601',
@PrimaryVendorID = 1,
@Status = N'Pending',
@DateEntered = N'1/12/07',
@Customer = N'myCustomer'

SELECT 'Return Value' = @return_value

GO

I think it is supposed to return the fields from the new record. Why
doesn't it? Does this wizard still not generate working stored procedures?

Thanks,
T
Jan 6 '07 #1
1 929
"Tina" <Ti**********@nospamexcite.comwrote in message
news:un**************@TK2MSFTNGP02.phx.gbl...
If I execute this SP in SQL Server Management Studio it returns zero
Do you mean it returns zero records, or you it returns you a value of
zero...?
Jan 7 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Benny | last post by:
Dear All, Suppose in the program a record is added to a table whose primary key is a identity field. If I really want to get the lastest value for that field after the insertion, is it the best...
2
by: Devesh Aggarwal | last post by:
Hi, I have a backup and restore module in my project. The backup uses a typed dataset object (XSD) to get the data from database and creates a xml file as the backup file (using the WriteXml...
7
by: Oenone | last post by:
Sorry for the cross-post but I've really no idea where this is best suited. I've an ADO.NET application which connects to a SQL Server database. I have spent the entire morning trying to get it...
1
by: Dave | last post by:
Not sure if you need more here, but I am sending all these values in an object. I am not sure how to get the Identity back from the SP using an object like this Public Shared Sub...
2
by: Wayne Wengert | last post by:
I have a VB.NET app in which I am using the following code to add a new row. ds.Tables("UnitsTable").Rows.Add(dr) ' Add the new row da.InsertCommand = cmdBuilder.GetInsertCommand da.Update(ds,...
41
by: pb648174 | last post by:
In a multi-user environment, I would like to get a list of Ids generated, similar to: declare @LastId int select @LastId = Max(Id) From TableMania INSERT INTO TableMania (ColumnA, ColumnB)...
3
by: Dave A | last post by:
Has anyone written or using an identity mapper design pattern in an enterprise framework? The identity mapper pattern is described in Martin Fowler's Patterns of Enterprise Application...
1
by: GaryDean | last post by:
I'm trying to get Identity back from a stored procedure in SQL Server. When I execute the SP in Management Studio @NewID is returned in the first row/first columm. but when I run the code below,...
13
by: PinkBishop | last post by:
I am using VS 2005 with a formview control trying to insert a record to my access db. The data is submitted to the main table no problem, but I need to carry the catID to the bridge table...
33
by: JamesB | last post by:
I am writing a service that monitors when a particular app is started. Works, but I need to get the user who is currently logged in, and of course Environment.UserName returns the service logon...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.