开发者

How to insert a data field into an empty table

开发者 https://www.devze.com 2022-12-24 19:37 出处:网络
I am making a front-end application in VB. The back-end is Oracle. I want an autogenerated ID on the click of a \"New\" button. It works well if data is present inthe table, but shows an error if the

I am making a front-end application in VB. The back-end is Oracle. I want an autogenerated ID on the click of a "New" button. It works well if data is present in the table, but shows an error if the table is empty. What do I need to insert so that it works when I am using the application for the first time? My button code is as follows:

Private Sub cmd_new_Click()
Call txt_clear
txt_name.Enabled = True
Set rsCat = New ADODB.Recordset
rsCat.Open "Category", conn, adOpenDynamic, adLockPessimistic

If rsCat.EOF = rscat.BOF Th开发者_Python百科en
    tempId = 1000
Else
    rsCat.MoveLast
    tempId = rsCat.Fields("Category_Id") + 1
End If

txt_Id = tempId
cmd_Save.Enabled = True
cmd_new = False

End Sub 


check rscat.RecordCount=-1 Basically, change

If rsCat.EOF = rscat.BOF Then

to

If rsCat.RecordCount=-1 Then
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号