Results 1 to 2 of 2

Thread: data entry app - retrieve Identity value

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2000
    Posts
    1
    SQL Server 7 and VB6

    The table in sql the primary key is an identity field, incremented by 1.

    I am creating a data entry app in vb and need to pull the next incremented value from sql in order to save the record.

    I have done this in oracle:
    declare global variable: Global gvCustid as long
    cmdAddnew:
    With deCes.rscdInvitee
    gvNextCustID = !nextval
    End With
    txtCustID.Text = gvNextCusID

    When I have tried this code I have been receiving the error: field not updatable, bound property.

    If this code is eliminated I receive the error from my code. :
    updateerror:
    MsgBox Err.Description, vbOKOnly + vbCritical, _
    "Error"
    The description is Errors Occured.

    Any advice would be greatly appreciated.

    Thank you

    Brandy

  2. #2
    Frenzied Member
    Join Date
    Aug 1999
    Location
    Santa Clara, Ca , 95058
    Posts
    1,105
    Don't use identity records in SQL server but that's another story. You don't pass a value to the identity field, SQL server does.

    You could find out what SQL server is going to set the value to by

    select max(identityFld) from table

    Just add the increment to the retrieved value. If you don't know (in this case you do) what the increment value is you can use the function "ident_incr" to determine it.

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