Solved

using select scope_identity()

Posted on 2006-06-13
4
337 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

708 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

15 Experts available now in Live!

Get 1:1 Help Now