> oCommand.CommandText = cSQL > > ' In SQL Server, we can get the primary key as is > If nBackend = 2 Then > oCommand.CommandText = oCommand.CommandText + "; SELECT SCOPE_IDENTITY() ;" > End If > > ' Only add the parameters if we have some > If oParameters2.Count > 0 Then > For Each oDataParameter In oParameters2 > oCommand.Parameters.Add(oDataParameter) > Next > End If > > oDataAdapter.SelectCommand = oCommand > oDataAdapter.SelectCommand.Connection.Open() > oDataAdapter.SelectCommand.ExecuteNonQuery() > > ' In SQL Server, we can get the primary key as is > If nBackend = 2 Then > nPrimaryKey = oCommand.ExecuteScalar() > End If >On second thought, there is something wrong with this code. For each insert, there are now two records being inserted. This is like that since I added the SELECT SCOPE_IDENTITY() in the SQL with the ExecuteScalar().