I'm using the OleDBConnectivity system to connect and use a Microsoft Access database.
I'm adding a record to the table in the database called "PayInfo", and the primary key is automatically set to the next available integer. How do I check what the value of the primary key it was assigned to is? I know this is probably an awful idea, but the only thing I could think of was to re-read the database using the entered values. The issue with this, though it's very unlikely, is that its possible to have 2 identical records stored in the database, their only difference being the primary key, and I need to be able to read the specific one.
My current subroutine for adding the record to the database is as follows:
OleDbCommand command = connection.CreateCommand();
connection.Open();
// The SQL statement:
command.CommandText = "INSERT INTO PayInfo ([UserID], [FullName], [CardType], [CardNo], [CVV], [ExpDate], [Address])" +
"VALUES ('" + Global.UserID.ToString() + "','" + PayInfo[6] + "','" + PayInfo[0] + "','" + PayInfo[1] + "','" + PayInfo[2] + "','" + exp + "','" + adress + "')";
command.Connection = connection;
command.ExecuteNonQuery(); //executes the SQL command.
connection.Close();
return true; //Successful transaction