Hey everyone, I know there are literally thousands of questions and answers on the internet for getting the SCOPE_IDENTITY(), but I haven't found a single one that relates to my particular situation... So here we go...
I've decided to use VS .NET's built in Data Components, which in my case doing things the mainstream easy way always turns out to be the hard way for me... So anyway, here's my VB .NET code... Notice the line that is commented, that's where I need to get the SCOPE_IDENTITY().
Private Sub SaveChangesToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveChangesToolStripMenuItem.Click
If Integer.Parse(contactId) = 0 Then
Try
Me.Validate()
Me.CRM_ContactsBindingSource.AddNew()
Me.TableAdapterManager.UpdateAll(Me.DB_6b3044DataSet)
' contactID = ''' Some how need to get the Scope_Identity '''
Catch ex As System.Exception
System.Windows.Forms.MessageBox.Show(ex.Message)
End Try
Else
Try
Me.Validate()
Me.CRM_ContactsBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.DB_6b3044DataSet)
Catch ex As System.Exception
System.Windows.Forms.MessageBox.Show(ex.Message)
End Try
End If
RefreshContactsDataGridWithContactID()
CRM_ContactsDataGridView.Visible = True
editDetailsViewPanel.Visible = False
detailsViewPanel.Visible = True
SaveChangesToolStripMenuItem.Visible = False
CancelChangesToolStripMenuItem.Visible = False
AddContactToolStripMenuItem.Visible = True
End Sub