I’m adding a record like this:
Dim pathString As String = HttpContext.Current.Request.MapPath('Banking.mdb') Dim odbconBanking As New OleDbConnection _ ('Provider=Microsoft.Jet.OLEDB.4.0;' & _ 'Data Source=' + pathString) Dim sql As String sql = 'INSERT INTO tblUsers ( FirstName, LastName, Address, City, Province, Zip, Phone, UserName, [Password])' & _ ' VALUES ('' & firstName & '', '' & lastName & '', '' & address & _ '', '' & city & '', '' & province & '', '' & zip & '', '' & phone & '', '' & username & '', '' & password & '');' odbconBanking.Open() Dim cmd As New OleDbCommand(sql, odbconBanking) cmd.ExecuteNonQuery() odbconBanking.Close()
The primary key is an autonumber field called UserID. So, how do I get the primary key of the record I just inserted?
Thanks.
I believe a parameterized query would look something like this:
My syntax might be a bit off as I am more accustomed to using the Sql Server library and not the Odbc library, but that should get you started.