Results 1 to 3 of 3

Thread: SCOPE_IDENTITY() SqlCE Problem

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2007
    Posts
    8

    SCOPE_IDENTITY() SqlCE Problem

    I am unable to do the SCOPE_IDENTITY on a insert query at SQL Mobile.


    I need to perform on this query the insert on Client table and to get the ID.

    I am programming on Visual Basic on Visual Studio 2005


    My code is:
    vb Code:
    1. Dim ClientID as Integer
    2.  
    3. Dim sql As String = "INSERT INTO Client(Number) VALUES('5'); SELECT scope_identity()"
    4.  
    5. Dim cmd As New SqlCeCommand(sql, connection)
    6.  
    7.  
    8. connection.Open()
    9.  
    10. ClientID = Convert.ToInt32(cmd.ExecuteNonQuery())
    11.  
    12. connection.Close()
    And I get an error like this:

    There was an error parsing the query. [ Token line number = 1,Token line offset = 76,Token in error = SELECT ]



    Thanks!

  2. #2
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    Re: SCOPE_IDENTITY() SqlCE Problem

    Hi,
    you can't string multiple commands together in SqlMobile

    Pete
    Pete Vickers
    MVP - Device Application Development
    http://www.gui-innovations.com http://mobileworld.appamundi.com/blogs/

  3. #3

    Thread Starter
    New Member
    Join Date
    Apr 2007
    Posts
    8

    Re: SCOPE_IDENTITY() SqlCE Problem

    Thank's! Problem resolved! I just had to separate my query in two querys!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width