问题描述
我要做的是将新记录存储在Access数据库中并将其读回以获取自动生成的记录ID。
如果searchid = 0那么
'sla de nieuwe zoekstring op en sla de zoek resultaten op。
CvmetadataDataSet.SearchStrings.AddSearchStringsRow(quicksearchstring(2))
SearchStringsBindingSource.EndEdit()
SearchStringsTableAdapter.Update(CvmetadataDataSet.SearchStrings)
newstring = True
每个项目在CvmetadataDataSet.SearchStrings中
如果item.Searchstring = quicksearchstring(2)那么
searchid = item.SearchID
退出
结束如果
下一页
否则
当我运行此代码时,变量searchid返回值-1。关闭程序并检查数据库后,我可以看到记录存储了正确的ID。如何获取真实的id值?
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?
这篇关于如何获得新记录的ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!