aviles1973
Programmer
I have recently created a topic about retrieving the value of an Identity column that is an autonumber primary key field in SQLServer2005.
Thanks to all for the posts. Even though I do understand the SQL Language and the insert command. I still am stuck on this topic because I am only using SQL to fill my DataAdapter as in:
m_daDataAdapter = New SqlClient.SqlDataAdapter("Select * From Contacts", m_cnADONetConnection)
Then I'm using this approach to add new records:
Dim drNewRow As DataRow = m_dtContacts.NewRow()
FNameNEW.Text = StrConv(FNameNEW.Text, VbStrConv.ProperCase)
LNameNEW.Text = StrConv(LNameNEW.Text, VbStrConv.ProperCase)
drNewRow("FirstName") = FNameNEW.Text
drNewRow("LastName") = LNameNEW.Text
drNewRow("PhoneNumber") = PhoneNumNEW.Text
m_dtContacts.Rows.Add(drNewRow)
m_daDataAdapter.Update(m_dtContacts)
'
m_rowPosition = m_dtContacts.Rows.Count - 1
Me.ShowCurrentRecord()
So where in the above code and what code should I use to retrieve the identity of the newly inserted ContactID column without resetting and refilling the DataTable?
STUMPED!!!!
Thanks to all for the posts. Even though I do understand the SQL Language and the insert command. I still am stuck on this topic because I am only using SQL to fill my DataAdapter as in:
m_daDataAdapter = New SqlClient.SqlDataAdapter("Select * From Contacts", m_cnADONetConnection)
Then I'm using this approach to add new records:
Dim drNewRow As DataRow = m_dtContacts.NewRow()
FNameNEW.Text = StrConv(FNameNEW.Text, VbStrConv.ProperCase)
LNameNEW.Text = StrConv(LNameNEW.Text, VbStrConv.ProperCase)
drNewRow("FirstName") = FNameNEW.Text
drNewRow("LastName") = LNameNEW.Text
drNewRow("PhoneNumber") = PhoneNumNEW.Text
m_dtContacts.Rows.Add(drNewRow)
m_daDataAdapter.Update(m_dtContacts)
'
m_rowPosition = m_dtContacts.Rows.Count - 1
Me.ShowCurrentRecord()
So where in the above code and what code should I use to retrieve the identity of the newly inserted ContactID column without resetting and refilling the DataTable?
STUMPED!!!!