Advertisement

02.15.2008 at 12:59PM PST, ID: 23167298
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

VB .Net Code to insert a row in SQL Server 2005 Express and get back Identity

Tags: SQL Server, VB .Net 2005/2008
Hello experts,

I need help if you could please? I would like help calling a stored procedure (attached code snippet) from VB .Net 2005/2008.  I have the SP as good as I an get it, but I need the VB .Net code to call this.

Here's what I'd like to happen:
1. I pass in the details of the new contact to the SP
2. SP inserts the data
3. Auto number field on the ContactID column is automatically generated by SQL Server
4. Within the same SP, the identity column should be looked up and returned back to the calling code
5. The calling code displays this number in a big, old fashioned message box.

Thats it!  Full marks to the person that gets me *working* code first.  For the record, the SQL Server Express install is on the same development machine... MyPC.

On your marks, get set.... GO!

Any help is much appreciated.

Thanks

Brett
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[spAddContact]
		
	-- Add the parameters for the stored procedure here
	@My_Identity_Key INT = null OUTPUT,
	@Title varchar(50),
	@Firstname varchar(50),
	@Middlename varchar(50),
	@Surname varchar(50)		
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;
 
    -- Insert statements for procedure here
	INSERT INTO [Contacts].[dbo].[tbContacts]
           ([Title]
           ,[Firstname]
           ,[Middlename]
           ,[Surname])           
     VALUES
           (@Title,
           @Firstname, 
           @Middlename, 
           @Surname
           );
 
DECLARE	@return_value int
		--@My_Identity_Key int
 
SELECT	@My_Identity_Key as N'@My_Identity_Key'
 
SELECT	'Return Value' = @return_value
END
Start your free trial to view this solution
Question Stats
Zone: Microsoft
Question Asked By: raggedyboo
Solution Provided By: VBRocks
Participating Experts: 2
Solution Grade: A
Views: 188
Translate:
Loading Advertisement...
02.15.2008 at 01:55PM PST, ID: 20906392

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.15.2008 at 02:37PM PST, ID: 20906666

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.15.2008 at 03:21PM PST, ID: 20906940

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.15.2008 at 06:09PM PST, ID: 20907673

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
20080236-EE-VQP-29 / EE_QW_2_20070628