SqlitePulse.Insert C# (CSharp) Method

Insert() public static method

public static Insert ( bool dbconOpened, string tableName, string uniqueID, int personID, int sessionID, string type, double fixedPulse, int totalPulsesNum, string timeString, string description, int simulated ) : int
dbconOpened bool
tableName string
uniqueID string
personID int
sessionID int
type string
fixedPulse double
totalPulsesNum int
timeString string
description string
simulated int
return int
    public static int Insert(bool dbconOpened, string tableName, string uniqueID, int personID, int sessionID, string type, double fixedPulse, int totalPulsesNum, string timeString, string description, int simulated)
    {
        if(! dbconOpened)
            Sqlite.Open();

        if(uniqueID == "-1")
            uniqueID = "NULL";

        dbcmd.CommandText = "INSERT INTO " + tableName +
                " (uniqueID, personID, sessionID, type, fixedPulse, totalPulsesNum, timeString, description, simulated)" +
                " VALUES (" + uniqueID + ", " + personID + ", " + sessionID + ", \"" + type + "\", "
                + Util.ConvertToPoint(fixedPulse) + ", " + totalPulsesNum + ", \""
                + timeString + "\", \"" + description + "\", " + simulated + ")" ;
        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;
    }

Usage Example

Beispiel #1
0
    protected override void write()
    {
        int totalPulsesNum = 0;

        totalPulsesNum = Util.GetNumberOfJumps(timesString, false);

        uniqueID = SqlitePulse.Insert(false, Constants.PulseTable, "NULL", personID, sessionID, type,
                                      fixedPulse, totalPulsesNum, timesString,
                                      "", Util.BoolToNegativeInt(simulated) //description
                                      );

        //define the created object
        eventDone = new Pulse(uniqueID, personID, sessionID, type, fixedPulse, totalPulsesNum, timesString, "", Util.BoolToNegativeInt(simulated));

        //string myStringPush =   Catalog.GetString("Last pulse") + ": " + personName + " " + type ;
        if (simulated)
        {
            feedbackMessage = Catalog.GetString(Constants.SimulatedMessage);
        }
        else
        {
            feedbackMessage = "";
        }
        needShowFeedbackMessage = true;


        //app1.PreparePulseGraph(Util.GetLast(timesString), timesString);
        PrepareEventGraphPulseObject = new PrepareEventGraphPulse(Util.GetLast(timesString), timesString);
        needUpdateGraphType          = eventType.PULSE;
        needUpdateGraph = true;
        needEndEvent    = true;      //used for hiding some buttons on eventWindow, and also for updateTimeProgressBar here
    }
All Usage Examples Of SqlitePulse::Insert