how to get the last record number after inserting record to database in access

前端 未结 5 724
[愿得一人]
[愿得一人] 2021-02-05 21:40

i have database in access with auto increase field (ID).

i insert record like this (in C#)

SQL = \"insert into TermNumTbl (DeviceID,IP) valu         


        
5条回答
  •  暖寄归人
    2021-02-05 22:06

     query = "Insert Into jobs (jobname,daterecieved,custid) Values ('" & ProjectNAme & "','" & FormatDateTime(Now, DateFormat.ShortDate) & "'," & Me.CustomerID.EditValue & ");"'Select Scope_Identity()"
            ' Using cn As New SqlConnection(connect)
    
              Using cmd As New OleDb.OleDbCommand(query, cnPTA)
                    cmd.Parameters.AddWithValue("@CategoryName", OleDb.OleDbType.Integer)
                    If cnPTA.State = ConnectionState.Closed Then cnPTA.Open()
                    ID = cmd.ExecuteNonQuery
              End Using
    

提交回复
热议问题