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. Database & SysAdmin
  3. Database
  4. @@Identity.....Help Me somebody

@@Identity.....Help Me somebody

Scheduled Pinned Locked Moved Database
helpdatabasesql-serversysadmin
5 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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    Hi, I really need help with a major problem I have encountered. I'm trying to insert information into a SQL Server 2000 database using stored procedures. And each table that has a Primary Key (int) won't return a value using SELECT @@IDENTITY. The error states that ArtistID doesn't except null values and will not insert into table. Here's the source code for the stored procedure: CREATE PROCEDURE ArtXchangeWeb.procManagerInsertArtist @ArtistFName text, @ArtistLName text, @ArtistBirth text, @ArtistDeath text, @ArtistCountry text, @ArtistNationality text, @ArtistMovement text, @ArtistBio text, @ArtistPhoto varchar(255) AS BEGIN INSERT INTO Artist(ArtistFName, ArtistLName, ArtistBirth, ArtistDeath, ArtistCountry, ArtistNationality, ArtistMovement, ArtistBio, ArtistPhoto) VALUES(@ArtistFName, @ArtistLName, @ArtistBirth, @ArtistDeath, @ArtistCountry, @ArtistNationality, @ArtistMovement, @ArtistBio, @ArtistPhoto) /* Return the ID of the new artist */ SELECT @@IDENTITY END GO If it doesn't give me the previous error it gives me a Input String not the right type error. Here's the code behind .vb: If IsPostBack Then 'Save the new product to the database With cmdManagerInsertArtist .Parameters("@ArtistFName").Value = txtFName.Text() .Parameters("@ArtistLName").Value = txtLName.Text() .Parameters("@ArtistBirth").Value = txtBirth.Text() .Parameters("@ArtistDeath").Value = txtDeath.Text() .Parameters("@ArtistCountry").Value = ddlCountry.SelectedItem.Text .Parameters("@ArtistMovement").Value = ddlMovement.SelectedItem.Text .Parameters("@ArtistNationality").Value = ddlNationality.SelectedItem.Text .Parameters("@ArtistBio").Value = txtBio.Text() .Parameters("@ArtistPhoto").Value = txtArtistImg.Text() cnn.Open() Session("ArtistID") = .ExecuteScalar cnn.Close() 'And redirect to the management page Server.Transfer("ManageArtist.aspx") End With If you can help me out that would be greatful. I wouldn't be a programmer if it wasn't for sites like yours and I've searched around for answer to my problem and to no avail I'm still stuck in the same spot. I hope you can help me. Thanks, Gregory Foreman

    D 1 Reply Last reply
    0
    • L Lost User

      Hi, I really need help with a major problem I have encountered. I'm trying to insert information into a SQL Server 2000 database using stored procedures. And each table that has a Primary Key (int) won't return a value using SELECT @@IDENTITY. The error states that ArtistID doesn't except null values and will not insert into table. Here's the source code for the stored procedure: CREATE PROCEDURE ArtXchangeWeb.procManagerInsertArtist @ArtistFName text, @ArtistLName text, @ArtistBirth text, @ArtistDeath text, @ArtistCountry text, @ArtistNationality text, @ArtistMovement text, @ArtistBio text, @ArtistPhoto varchar(255) AS BEGIN INSERT INTO Artist(ArtistFName, ArtistLName, ArtistBirth, ArtistDeath, ArtistCountry, ArtistNationality, ArtistMovement, ArtistBio, ArtistPhoto) VALUES(@ArtistFName, @ArtistLName, @ArtistBirth, @ArtistDeath, @ArtistCountry, @ArtistNationality, @ArtistMovement, @ArtistBio, @ArtistPhoto) /* Return the ID of the new artist */ SELECT @@IDENTITY END GO If it doesn't give me the previous error it gives me a Input String not the right type error. Here's the code behind .vb: If IsPostBack Then 'Save the new product to the database With cmdManagerInsertArtist .Parameters("@ArtistFName").Value = txtFName.Text() .Parameters("@ArtistLName").Value = txtLName.Text() .Parameters("@ArtistBirth").Value = txtBirth.Text() .Parameters("@ArtistDeath").Value = txtDeath.Text() .Parameters("@ArtistCountry").Value = ddlCountry.SelectedItem.Text .Parameters("@ArtistMovement").Value = ddlMovement.SelectedItem.Text .Parameters("@ArtistNationality").Value = ddlNationality.SelectedItem.Text .Parameters("@ArtistBio").Value = txtBio.Text() .Parameters("@ArtistPhoto").Value = txtArtistImg.Text() cnn.Open() Session("ArtistID") = .ExecuteScalar cnn.Close() 'And redirect to the management page Server.Transfer("ManageArtist.aspx") End With If you can help me out that would be greatful. I wouldn't be a programmer if it wasn't for sites like yours and I've searched around for answer to my problem and to no avail I'm still stuck in the same spot. I hope you can help me. Thanks, Gregory Foreman

      D Offline
      D Offline
      Daniel Turini
      wrote on last edited by
      #2

      Can you send us the table definition? It seems that the ArtistID column is not an IDENTITY column.. Could you check it? Another tip: MS does not recommend you to use the @@IDENTITY for this, because it has a nasty definition that causes some weird bugs with triggers. Always use the SCOPE_IDENTITY() function. Q261186 - Computer Randomly Plays Classical Music

      M 1 Reply Last reply
      0
      • D Daniel Turini

        Can you send us the table definition? It seems that the ArtistID column is not an IDENTITY column.. Could you check it? Another tip: MS does not recommend you to use the @@IDENTITY for this, because it has a nasty definition that causes some weird bugs with triggers. Always use the SCOPE_IDENTITY() function. Q261186 - Computer Randomly Plays Classical Music

        M Offline
        M Offline
        Morten Abrahamsen
        wrote on last edited by
        #3

        Yes, the ArtistId can't be an IDENTITY column if that message appears. He should also consider using a different datatype than the all-mighty "text" for his input parameters. Morty

        D 1 Reply Last reply
        0
        • M Morten Abrahamsen

          Yes, the ArtistId can't be an IDENTITY column if that message appears. He should also consider using a different datatype than the all-mighty "text" for his input parameters. Morty

          D Offline
          D Offline
          Daniel Turini
          wrote on last edited by
          #4

          Morten Abrahamsen wrote: He should also consider using a different datatype than the all-mighty "text" for his input parameters. God! I didn't even noticed that! :eek: :omg: Q261186 - Computer Randomly Plays Classical Music

          M 1 Reply Last reply
          0
          • D Daniel Turini

            Morten Abrahamsen wrote: He should also consider using a different datatype than the all-mighty "text" for his input parameters. God! I didn't even noticed that! :eek: :omg: Q261186 - Computer Randomly Plays Classical Music

            M Offline
            M Offline
            Morten Abrahamsen
            wrote on last edited by
            #5

            Yeah.. and that sort of sucks because that specific type is (sometimes?) transferred differently than normal SQL statements/types in order to handle the large amount of data it MIGHT contain. (2 147 483 647 bytes to be exact) ;) Morty

            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