public static int Insert(bool dbconOpened, string uniqueID, string name, string sex, DateTime dateBorn,
int race, int countryID, string description, int serverUniqueID)
{
LogB.SQL("going to insert");
if(! dbconOpened)
Sqlite.Open();
if(uniqueID == "-1")
uniqueID = "NULL";
// -----------------------
//ATTENTION: if this changes, change the Person.ToSQLInsertString()
// -----------------------
string myString = "INSERT INTO " + Constants.PersonTable +
" (uniqueID, name, sex, dateBorn, race, countryID, description, future1, future2, serverUniqueID) VALUES (" + uniqueID + ", \"" +
name + "\", \"" + sex + "\", \"" + UtilDate.ToSql(dateBorn) + "\", " +
race + ", " + countryID + ", \"" + description + "\", \"\", \"\", " + serverUniqueID + ")";
dbcmd.CommandText = myString;
LogB.SQL(dbcmd.CommandText.ToString());
dbcmd.ExecuteNonQuery();
//int myLast = -10000; //dbcon.LastInsertRowId;
//http://stackoverflow.com/questions/4341178/getting-the-last-insert-id-with-sqlite-net-in-c
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;
}