?
Solved

using select scope_identity()

Posted on 2006-06-13
4
Medium Priority
?
367 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 1000 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

771 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