Getting last value and increasing it by one

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Renar
    New Member
    • Jul 2007
    • 2

    Getting last value and increasing it by one

    Hello,
    My name is Tim and I am new here so i would just like to start of with saying hi to everyone!

    the problem i have is i am using asp.net and SQL and I want to get the last value of the called vidid and increase it by one.

    I have found this code
    SELECT MAX(vidid) + 1
    FROM dbo.Videos

    I am using dreamweaver 8 and I use the test button and it submits it and comes up with the value i want.

    I then press ok and go to bindings to get the value and there are no binding so i wrote the code in my self and it does not display anything not even a error msg.

    I have also tryed this code

    SELECT vidid + 1
    FROM dbo.Videos
    ORDER BY vidid DESC

    This does not work aswell but if i remove the + 1 then i see that last value.

    Any ideas ?? like alternate code

    Thanks

    Tim
  • DonlonP
    New Member
    • Jul 2007
    • 25

    #2
    Originally posted by Renar
    Hello,
    My name is Tim and I am new here so i would just like to start of with saying hi to everyone!

    the problem i have is i am using asp.net and SQL and I want to get the last value of the called vidid and increase it by one.

    I have found this code
    SELECT MAX(vidid) + 1
    FROM dbo.Videos

    I am using dreamweaver 8 and I use the test button and it submits it and comes up with the value i want.

    I then press ok and go to bindings to get the value and there are no binding so i wrote the code in my self and it does not display anything not even a error msg.

    I have also tryed this code

    SELECT vidid + 1
    FROM dbo.Videos
    ORDER BY vidid DESC

    This does not work aswell but if i remove the + 1 then i see that last value.

    Any ideas ?? like alternate code

    Thanks

    Tim
    Hi Tim,

    I'm not familiar with dreamweaver but your original SQL query should work. If it returns a value in query analyser then make sure you're binding it correctly and also check your database connection string in .net.

    Comment

    • Renar
      New Member
      • Jul 2007
      • 2

      #3
      Originally posted by DonlonP
      Hi Tim,

      I'm not familiar with dreamweaver but your original SQL query should work. If it returns a value in query analyser then make sure you're binding it correctly and also check your database connection string in .net.
      hello thanks for responding...
      i used a sqlcommand instead and its working now but thanks anyway.

      Comment

      • hoomaniraji
        New Member
        • Jul 2007
        • 10

        #4
        hi
        if you use this value for inserting new record in a multi user application your solution may not work.check it.

        Comment

        Working...