Here we go again.
I am in a situation where I need to retrieve a primary key auto number value from a table in my Access database.
To set the scene:
Attached to a button is the code to enter personal details to the table, this causes a primary key to be auto generated.
Straight after that I want to retrieve the auto number so that I can put it in a variable and then a booking can be created for that customer.
To retrieve value i am after I have used this code:
I understand that there are bits missing from this, however I can not get the data reader to work correctly. If anyone can help with the code here, I would be grateful.
Thanks in advance
Graham
I am in a situation where I need to retrieve a primary key auto number value from a table in my Access database.
To set the scene:
Attached to a button is the code to enter personal details to the table, this causes a primary key to be auto generated.
Straight after that I want to retrieve the auto number so that I can put it in a variable and then a booking can be created for that customer.
To retrieve value i am after I have used this code:
VB.NET:
Dim sqlsearch As String = "SELECT customerID from tblCustomer WHERE customerfirstname = firstname AND customersurname = surname AND postcode = postcode"
'Creates a variable command so that the sql and connection variables are run
Dim command1 As New System.Data.OleDb.OleDbCommand(sqlsearch, connect)
connect.Open()
MsgBox("A Connection to the Database is now open")
connect.Close()
MsgBox("The Connection to the Database is now Closed")
Thanks in advance
Graham