Solved

using select scope_identity()

Posted on 2006-06-13
4
345 Views
Last Modified: 2010-04-16
Hello,

I have  the following insert statemet that  I want to use and return the identity column created by using this. Howerver evenig i used select scope_identity it is not retruning the identity. Any ideas
string LoInsert =("INSERT INTO mms.dbo.user_inf (UserName,PasswordHint,UserAlternateLogin)" +
                     "Select l.lo_login,'Email',l.email_address from INTRANET.dbo.lo_information l where l.email_address='" + (alternateLogin) + "' and '" + (username) + "' = null SELECT SCOPE_IDENTITY()");


thank you so much
0
Comment
Question by:jemigossaye
  • 2
  • 2
4 Comments
 
LVL 25

Expert Comment

by:dstanley9
ID: 16896973
How are you executing the query (ExecuteNonQuery, ExecuteScalar, etc.) ?  Are you expecting a return value or a result set?  
0
 

Author Comment

by:jemigossaye
ID: 16897046
I am executing using executeScalar() exepect like this

userId =Convert.ToInt32(LoCommand.ExecuteScalar());
0
 
LVL 25

Accepted Solution

by:
dstanley9 earned 250 total points
ID: 16897226
Are you sure it's inserting any rows?  You insert clause

"where l.email_address='" + (alternateLogin) + "' and '" + (username) + "' = null"

Would not return any rows since it would be comparing '{username}' = null, which would always be false.
0
 

Author Comment

by:jemigossaye
ID: 16897274
thank you that was my problem. NO idea what i was thinking
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Error in JQuery 5 51
application restarter  - for an exe that hangs 9 24
Hey!!!! 1 20
Get distinct values from excel or comm seperated file 4 23
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

815 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now