Click here to Skip to main content
15,895,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
What I'm trying to do is store a new record in an Access database and read it back to get the automatic generated record-id back.

If searchid = 0 Then
'sla de nieuwe zoekstring op en sla de zoek resultaten op.
CvmetadataDataSet.SearchStrings.AddSearchStringsRow(quicksearchstring(2))
SearchStringsBindingSource.EndEdit()
SearchStringsTableAdapter.Update(CvmetadataDataSet.SearchStrings)

newstring = True
For Each item In CvmetadataDataSet.SearchStrings
If item.Searchstring = quicksearchstring(2) Then
searchid = item.SearchID
Exit For
End If
Next
Else

When I run this code the variable searchid gets back the value -1. After I close the program and check the database I can see that the record is stored with a proper ID. How can I get the real id value?
Posted

1 solution

This MS Support article[^] describes what you need to do
 
Share this answer
 
Comments
[no name] 28-Jan-15 14:34pm    
It was a bit of a puzzle but I solved it. Thanks for putting me in the right direction.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900