Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to get the SELECT SCOPE_IDENTITY() - alternative

How to get the SELECT SCOPE_IDENTITY() - alternative

Scheduled Pinned Locked Moved C#
databasesql-servercomsysadmintutorial
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    ziwez0
    wrote on last edited by
    #1

    I have A Sql compact database and im trying to return the ID of the record just inserted, howerver multi queries are not support, http://msdn.microsoft.com/en-us/library/system.data.sqlserverce.sqlcecommand.aspx[^] "The Data Provider for Microsoft SQL Server 2005 Everywhere Edition does not support batched queries. Commands must be in the following form:" Select * from Customers and not Select * from Customers; Select * from Orders; Any solutions on how to write an alternative?

    C Z E 3 Replies Last reply
    0
    • Z ziwez0

      I have A Sql compact database and im trying to return the ID of the record just inserted, howerver multi queries are not support, http://msdn.microsoft.com/en-us/library/system.data.sqlserverce.sqlcecommand.aspx[^] "The Data Provider for Microsoft SQL Server 2005 Everywhere Edition does not support batched queries. Commands must be in the following form:" Select * from Customers and not Select * from Customers; Select * from Orders; Any solutions on how to write an alternative?

      C Offline
      C Offline
      CodingYoshi
      wrote on last edited by
      #2

      What if you send the query to insert. Then send another query to get the identity.

      CodingYoshi Visual Basic is for basic people, C# is for sharp people. Farid Tarin '07

      Z 1 Reply Last reply
      0
      • C CodingYoshi

        What if you send the query to insert. Then send another query to get the identity.

        CodingYoshi Visual Basic is for basic people, C# is for sharp people. Farid Tarin '07

        Z Offline
        Z Offline
        ziwez0
        wrote on last edited by
        #3

        Thats what im looking at at the moment, what happends if another user has entered a record to? possible issue?

        1 Reply Last reply
        0
        • Z ziwez0

          I have A Sql compact database and im trying to return the ID of the record just inserted, howerver multi queries are not support, http://msdn.microsoft.com/en-us/library/system.data.sqlserverce.sqlcecommand.aspx[^] "The Data Provider for Microsoft SQL Server 2005 Everywhere Edition does not support batched queries. Commands must be in the following form:" Select * from Customers and not Select * from Customers; Select * from Orders; Any solutions on how to write an alternative?

          Z Offline
          Z Offline
          ziwez0
          wrote on last edited by
          #4

          Also its a transactional statement

          1 Reply Last reply
          0
          • Z ziwez0

            I have A Sql compact database and im trying to return the ID of the record just inserted, howerver multi queries are not support, http://msdn.microsoft.com/en-us/library/system.data.sqlserverce.sqlcecommand.aspx[^] "The Data Provider for Microsoft SQL Server 2005 Everywhere Edition does not support batched queries. Commands must be in the following form:" Select * from Customers and not Select * from Customers; Select * from Orders; Any solutions on how to write an alternative?

            E Offline
            E Offline
            Ennis Ray Lynch Jr
            wrote on last edited by
            #5

            use @@IDENTITY or a Stored Procedure?

            Need custom software developed? I do C# development and consulting all over the United States. A man said to the universe: "Sir I exist!" "However," replied the universe, "The fact has not created in me A sense of obligation." --Stephen Crane

            Z 1 Reply Last reply
            0
            • E Ennis Ray Lynch Jr

              use @@IDENTITY or a Stored Procedure?

              Need custom software developed? I do C# development and consulting all over the United States. A man said to the universe: "Sir I exist!" "However," replied the universe, "The fact has not created in me A sense of obligation." --Stephen Crane

              Z Offline
              Z Offline
              ziwez0
              wrote on last edited by
              #6

              good idea but same problem

              E 1 Reply Last reply
              0
              • Z ziwez0

                good idea but same problem

                E Offline
                E Offline
                Ennis Ray Lynch Jr
                wrote on last edited by
                #7

                ? Sql Server CE doesn't support multiple concurrent connections. Did you try it like this? command.CommandText = "Your Insert Statement"; command.Execute(); command.Parameters.Clear(); command.Parameters.Add("@id", ..."); ... command.CommandText = "SET @id = @@IDENTITY"; command.ExecuteNonQuery();

                Need custom software developed? I do C# development and consulting all over the United States. A man said to the universe: "Sir I exist!" "However," replied the universe, "The fact has not created in me A sense of obligation." --Stephen Crane

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups