Public Function nLog(ByVal cDescription As String, Optional ByVal cCaller As String = "Immediate Window") As Integer Dim da As New dsLogTableAdapters.logTableAdapter ' Dim c As String = System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString() Dim cmdGetPK = New OleDbCommand() cmdGetPK.CommandText = "SELECT @@identity" da.Connection.Open() Dim n As Integer = da.Insert(My.Computer.Name, Environment.GetEnvironmentVariable("username"), LogType.LogNiceTohave, LogAction.logNa, Now, 0, "", cDescription, cCaller) cmdGetPK.Connection = da.Connection Dim n2 As Long = cmdGetPK.ExecuteScalar() da.Connection.Close() Return n2 End FunctionThe key is to issue the "SELECT @@identity" under the same connection as the insert.