PDA

Click to See Complete Forum and Search --> : data entry app - retrieve Identity value


toobeemore
Mar 31st, 2000, 01:55 AM
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

JHausmann
Mar 31st, 2000, 04:26 AM
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.