I have a program which records ID,Name,TimeIn,TimeOut. On the first scan of a card it record the id,name and timein, and then on second swipe it adds to the timeout column. I am trying to get it to add another "TimeIn" column on the third swipe, so I tried to get it to insert "TimeIn + Unique Number", but it does not pick up the variable due to the quotes.
Here is my code:
private void SignIn_Time(OleDbCommand updateCmd, OleDbConnection OLEDB_Connection, Object varName, Object varID, String varTime)
{
object varTimeColumn;
varTimeColumn = "TimeIn" + GetUniqueNumber();
updateCmd.CommandText = "ALTER TABLE TestDB ADD COLUMN varTimeColumn TEXT";
updateCmd.CommandText = "INSERT INTO TestDB (varTimeColumn) VALUES (@TIMEIN)";
updateCmd.Parameters.AddWithValue("@TIMEIN", varTime);
OLEDB_Connection.Open();
updateCmd.Connection = OLEDB_Connection;
updateCmd.ExecuteNonQuery();
OLEDB_Connection.Close();
}
static int counter;
public static int GetUniqueNumber()
{
return counter++;
}