Has anyone ever succeeded to use the scope_identity() from the LabVIEW DB toolkit ?

Hi,
Using LabVIEW 2014 DS, and MSSQL 2008R2.
I have configured a table with identity, so the indexed will be incremented automatically.
I am trying to get the ID of the last Insert command that I am using.
I am trying to SELECT SCOPE_IDENTITY() but with no success.
I read about trying to so it with a procedure or transaction, but I just could not succeed myself.
Has anyone ever succeeded to use the scope_identity() from the LabVIEW DB toolkit ?
If yes, can you please elaborate more or even share the code ?
Thanks, 
Amitai.

Yes I have...let me dig out some code...
I do my INSERT query (with a semicolon at the end) and in the same query string do a "SELECT SCOPE_IDENTITY() as inserted_id;" - essentially what you're doing here is running two queries in one - one to insert your data and the second to retrieve the ID. From what I remember of when I did this (last year?), I think scope_identity() is valid for the same connection so as you're doing both queries in the same connection it should always be valid.
I then do this to get the ID (pardon the crappy VI snippet):
Essentially I execute the query and the result is a 2D array that contains one row/column which is your last inserted ID.
Certified LabVIEW Architect, Certified TestStand Developer
NI Days (and A&DF): 2010, 2011, 2013, 2014
NI Week: 2012, 2014
Knowledgeable in all things Giant Tetris and WebSockets

Similar Messages

  • Has anyone ever ran Logic using VMWare Workstation on a Windows PC?

    Has anyone ever emulated Mac OS X and used Logic on their x86 Microsoft Windows systems? I was thinking about doing this to use some synths and stuff with some Windows designed software. I'm not sure if it is possible to use both operating systems at the same time with VMWare Workstation operating system emulator. Help me out guys. Has anyone ever done it? Can it be done?

    VMWare Workstation will not run the client version of Mac OS X in emulation, and likely won't run Mac OS X Server either.
    (32050)

  • Has anyone ever validated CertPath using J2SDK1.4.0?

    I only installed J2SDK1.4.0
    I tried many example, but always got such error info:
    Validation failure, cert[2] :basic constraints check failed: this is not a CA certificate
    I have tried many situation, including creat and sign certificate with my own CA, or certificate signed by Verusign, or just Certpath from other website. All with same error.
    It seems it only works when there is only one Certification in CertPATH.
    below is a example I used, it got CerPath from website of www.ftc.gov and verify it.
    import java.net.*;
    import javax.net.*;
    import java.io.*;
    import javax.net.ssl.*;
    import java.security.cert.*;
    import java.util.*;
    import java.math.*;
    import java.security.*;
    public class t {
    public static void main(String args[ ])throws Exception {
    CertificateFactory cf = CertificateFactory.getInstance("X.509");
    try {
    // Create the client socket
    int port = 443;
    String hostname =args[0];
    SSLSocketFactory factory = HttpsURLConnection.getDefaultSSLSocketFactory();
    SSLSocket socket = (SSLSocket)factory.createSocket(hostname, port);
    // Connect to the server
    socket.startHandshake();
    // Retrieve the server's certificate chain
    java.security.cert.Certificate[] serverCerts =
    socket.getSession().getPeerCertificates();
         System.out.println(serverCerts.length);
    List mylist = new ArrayList();
    for(int i=0;i<serverCerts.length;i++){
    mylist.add((X509Certificate)serverCerts);
    CertPath cp = cf.generateCertPath(mylist);
    TrustAnchor anchor = new TrustAnchor((X509Certificate)serverCerts[serverCerts.length-1],null);
    PKIXParameters params = new PKIXParameters(Collections.singleton(anchor));
    params.setRevocationEnabled(false);
    CertPathValidator cpv = CertPathValidator.getInstance("PKIX");
    try {
    PKIXCertPathValidatorResult result =
    (PKIXCertPathValidatorResult) cpv.validate(cp, params);
    PolicyNode policyTree = result.getPolicyTree();
    PublicKey subjectPublicKey = result.getPublicKey();
    System.out.println("Certificate validated");
    System.out.println("Policy Tree:\n" + policyTree);
    System.out.println("Subject Public key:\n" +subjectPublicKey);
    } catch (CertPathValidatorException cpve) {
    System.out.println("Validation failure, cert["
    + cpve.getIndex() + "] :" + cpve.getMessage());
    // Close the socket
    socket.close();
    } catch (SSLPeerUnverifiedException e) {
    System.out.println(e);
    } catch (IOException e) {
    System.out.println(e);

    Do not include the trust anchor (root) certificate in the CertPath that is to be
    validated. Trust anchor certificates should not be included in the chain, they
    should only be specified separately in the PKIXParameters. It looks like this
    is the cause of the problem. Your trust anchor certificate is probably an
    X.509 V1 certificate and the PKIX CertPathValidator is rejecting it, since it
    is looking for a Basic Constraints extension to confirm that is a CA certificate,
    but X.509 V1 certificates do not have extensions. See RFC 3280 for more
    information.
    --Sean                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Has anyone had success in borrowing e books from the Toronto Public Library? I keep getting strange pages but cannot get to browsing e books.

    I wander if I missed a step in getting set up.

    I also have not been able to download the ebooks from TPL. I have no trouble going to "Safari Books online" for the computer technical manuals but the ebooks have been a bust for me as well.

  • Has anyone ever seen this on a iPhone 4s, the bar is upside down.

    Can someone explain this, it just happened out of knowhere. I turned the iPhone off and on and now its gone, but this is odd. Anyone?
    Romano

    That is a kernel panic. It happens when Mac OS X gets in a bind and cannot continue. The report will be saved and can be read out later using this article as a guide.
    Mac OS X: How to Log a kernel panic

  • Has anyone ever changed an apple id on the iphone

    my wife and i have been sharing an apple id and i now want to provide her with her own.  since the icloud has been launched any app she downloads i get and vice versa.  Has anyone ever switched out an applie id on the iphone before.  does it have to be synced with itunes once to make the change happen?  If so will i still be able to keep all of the contents ih her phone.

    You can share iTunes content within the same household, so if you get your own Apple ID/iTunes account, you can continue to use content obtained using your Wife's account. Any app updates to apps obtained using the wife's Id must be done using that ID. Just authorize the computer for the new Apple ID/iTunes account: Store>Authorize this Computer. You can switch iTunes accounts on the phone by going to: Settings>Store...tap the ID shown...sign out...sign back in with the ID you want to use.

  • My screen has streched out real big and the touch screen is difficult to use and can't return the screen to normal size.Has anyone ever experienced this?

    My screen has streched out real big and the touch screen is difficult to use and can't return the screen to normal size.Has anyone ever experienced this?

    Double-tap the screen with three fingers, then go to Settings and disable the Zoom function so you don't accidentally trigger it again.
    The User Guide is available at http://support.apple.com/manuals/ or downloadable from iTunes as an iBook.

  • TS1717 I get the following error message after installing the latest version of itunes via auto update:  "the itunes Library file cannot be saved. An unknown error occurred (-54). Has anyone ever seen this message and anyone have a suggestion what to do?

    I get the following error message after installing the latest version of itunes via auto update:  "the itunes Library file cannot be saved. An unknown error occurred (-54). Has anyone ever seen this message and anyone have a suggestion what to do?

    Hi pholewinski!
    I have a couple of articles for you here that I believe will help you with this issue. The first is an article on advanced troubleshooting, and it can be found here:
    iTunes: Advanced iTunes Store troubleshooting
    http://support.apple.com/kb/ts3297
    If following that article's steps doesn't take care of the issue, you can try the things listed in this article, which is about permissions issues in iTunes:
    iTunes: Missing folder or incorrect permissions may prevent authorization
    http://support.apple.com/kb/TS1277
    Thanks for using the Apple Support Communities. Have a good one!
    -Braden

  • Has anyone ever experienced the situation where plugging in the USB connector to the charging source (high-power USB port or Apple charger) halfway, then pressing it in firmly, results in the iPad not charging?

    Has anyone ever experienced the situation where plugging in the USB connector to the charging source (high-power USB port or Apple charger) halfway, then pressing it in firmly, results in the iPad not charging?

    It's highly likely that there is a poor connection in the phone - either a pin in the dock connector or internal wiring harness.  No software fixes or "tricks" would work, but I would recommend restoring in iTunes, first using a backup and if needed restore as a new phone. 
    Otherwise, opening and repairing the phone takes some tech knowledge that can't be relayed here.  Apple doesn't repair phones other than replacing batteries (not inconceivable that you have a bad battery), but offers "out-of-warranty" replacement (refurb) phones for $149 (US).  3rd party iPhone repair centers may be able to fix it for less.  Google to find them,
    Tried soft and hard resets
    FYI, there's no such thing as "soft" or "hard" resets in iPhone terminology.  There is only one phone reset. You'll see those terms thrown around by technically ignorant posters, but they mean different things to different people and are actually archaic, 1980s PC terms that have nothing to do with iPhones.
    See the User Guide, Appendix B.

  • Has anyone ever had this problem and know how to fix it!!! I upload songs on to my ipod and they appear on the ipod in iTunes but after I disconnect they are not on my ipod!

    has anyone ever had this problem and know how to fix it ?? I upload songs on to my ipod and they appear on my ipod in itunes but after i disconnect  (the correct way) the songs do not appear on my ipod. If i plug the ipod back into my computer it still shows them as being on my ipod through itunes but not when i disconnect please please please help!! thankyou! (Also the songs i'm trying to upload are cd's that i have brought)

    See Grouping tracks into albums, in particular the section Missing Artist or Album not with others by same artist.
    tt2

  • Has anyone noticed that songs which were previously in the genius list could not longer be used to created a genius play list?

    Has anyone noticed that songs which were previously in the genius list could not longer be used to created a genius play list?  Songs like "The Gambler" by Kenny Rogers or a Beach Boy song can no longer be recognized to create a genius play list.

    Has anyone noticed that songs which were previously in the genius list could not longer be used to created a genius play list?  Songs like "The Gambler" by Kenny Rogers or a Beach Boy song can no longer be recognized to create a genius play list.

  • Has anyone ever had the icons on the menu magnify?  My phone slipped onto the floor in my car and icons are now hugh.  Don't know how to fix it.

    Has anyone ever had the icons on the menu magnify?  My phone slipped onto the floor in my car and icons are now hugh.  Don't know how to fix it.

    Double tap the screen with 3 fingers.
    Stedman

  • Has anyone ever replaced a shattered screen on the iphone4?

    Has anyone ever replaced a shattered screen on the iphone4?

    Do you mean DIY?
    iPhone 4 Screen Repair - iPhone 4 Screen Repair: $99
    Apple Certified Techs, 1yr Warranty
    www.techrestore.com
    IPhone 4 Repair Parts | etechparts.com
    DIY iPhone 4 Screen, Glass, Back Cover and More. Wholesale!iPhone 4 Glass and Screen Assembly - iPhone 4 Glass Back Coverwww.etechparts.com/iPhone_4_Parts
    Otherwise, walk it into the nearest Apple Store otherwise and seek assistance there.
    Good luck in any case.

  • Has anyone ever lost a ringtone that they purchased and downloaded? I have; completely gone. And when I searched and attempted to download it again I got the message "you've already purchased this; do you want to purchase it again?"

    Has anyone ever lost a ringtone that they purchased and downloaded a ringtone and then it just completely disappeared? When I tried to download it again I got the message "You've already purchased this item; are you sure you want to buy it again?"

    You are aware that there the app may have downloaded and been placed on the second screen.  Not the main one.  Can you swipe to the right to see if it is there?

  • Has anyone ever had an email from Apple asking them to update their details for their Apple account on IPad? Kinda worried as it asks for my bank details and bank account number and security code on the back of the card. Thanks :)

    Has anyone ever had an email from Apple on IPad asking them to update their account details? The email seems genuine enough as it asks you to sign in with your Apple ID and password and takes you through to the Apple site but am a bit worried as they ask you in the section Update Your Apple account for bank and credit card details and for the security number on the back of the card. Also in the section where it asks for my mobile number it will only take 10 numbers and when ai try to put in the final (11th number) it won't let me. Sorry am new to all this and a bit confused! Any help is gratefully appreciated.....Thanks.

    That is phishing attack
    Someone, other then Apple, sent it to you
    Read http://support.apple.com/kb/ht4933
    Allan

Maybe you are looking for