public static int Insert(bool dbconOpened, string uniqueID, int personID, int sessionID,
double height, double weight, int sportID, int speciallityID, int practice,
string comments)
{
if(!dbconOpened)
Sqlite.Open();
if(uniqueID == "-1")
uniqueID = "NULL";
// -----------------------
//ATTENTION: if this changes, change the PersonSession.ToSQLInsertString()
// -----------------------
dbcmd.CommandText = "INSERT INTO " + Constants.PersonSessionTable +
"(uniqueID, personID, sessionID, height, weight, " +
"sportID, speciallityID, practice, comments, future1, future2)" +
" VALUES ("
+ uniqueID + ", " + personID + ", " + sessionID + ", " +
Util.ConvertToPoint(height) + ", " + Util.ConvertToPoint(weight) + ", " +
sportID + ", " + speciallityID + ", " + practice + ", \"" +
comments + "\", \"\", \"\")";
LogB.SQL(dbcmd.CommandText.ToString());
dbcmd.ExecuteNonQuery();
//int myLast = dbcon.LastInsertRowId;
//http://stackoverflow.com/questions/4341178/getting-the-last-insert-id-with-sqlite-net-in-c
string myString = @"select last_insert_rowid()";
dbcmd.CommandText = myString;
int myLast = Convert.ToInt32(dbcmd.ExecuteScalar()); // Need to type-cast since `ExecuteScalar` returns an object.
if(!dbconOpened)
Sqlite.Close();
return myLast;
}