mercredi 22 mars 2017

How can I use checkboxes for SQLite

I'm trying to set data type for SQLite checkbox in C#. Here's my code:

string sql = "CREATE TABLE 'tbl_selection' (" +
                    "'ID' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE, " +
                    "'int_isSelected' TEXT, " +
                    "'isSelected' INTEGER" +
                "); ";
command = new SQLiteCommand(sql, m_dbConnection);
command.ExecuteNonQuery();
sql = "CREATE TABLE IF NOT EXISTS 'tbl_build' (" +
            "'ID' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE, " +
            "'int_is64' TEXT, " +
            "'is64' INTEGER" +
        "); ";
command = new SQLiteCommand(sql, m_dbConnection);
command.ExecuteNonQuery();
sql = "CREATE TABLE IF NOT EXISTS 'tbl_programs' (" +
        "'ID' INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE, " +
        "'id_isSelected' INTEGER, " +
        "'txt_programName' TEXT, " +
        "'id_is64' INTEGER, " +
        "'id_fullCommand' INTEGER, " +
        "FOREIGN KEY('id_isSelected') REFERENCES 'tbl_selection'('isSelected'), " +
        "FOREIGN KEY('id_is64') REFERENCES 'tbl_build'('is64')" +
    "); ";
command = new SQLiteCommand(sql, m_dbConnection);
command.ExecuteNonQuery();
sql = "INSERT INTO tbl_selection (int_isSelected, isSelected) VALUES (1, 1)"; // true
command = new SQLiteCommand(sql, m_dbConnection);
command.ExecuteNonQuery();
sql = "INSERT INTO tbl_selection (int_isSelected, isSelected) VALUES (0, 2)"; // false
command = new SQLiteCommand(sql, m_dbConnection);
command.ExecuteNonQuery();
sql = "INSERT INTO tbl_build (int_is64, is64) VALUES (1, 1)";
command = new SQLiteCommand(sql, m_dbConnection);
sql = "INSERT INTO tbl_build (int_is64, is64) VALUES (0, 2)";

When I click checkbox on form I'm getting error which indicates this line:

batchOutput_tb.AppendText("START " +
            "\"" + row.Cells[2].Value.ToString() + "\" /WAIT " +
            row.Cells[4].Value.ToString() + Environment.NewLine);

And this error: An unhandled exception of type 'System.NullReferenceException' occurred in gazi_installer.exe Additional information: Object reference not set to an instance of an object.

How can I fix this? And is there a tutorial on the web for checkboxes for sqlite?




Aucun commentaire:

Enregistrer un commentaire