Maybe if we start at the very beginning?
When my app starts, I create the database if it does not exist, and then connect to it.
All ok so far.
In the ColoursWindow Open event , I have the following code:
// POPULATE THE COLOURS LISTBOX
PopulateColours(Listbox2,db,"SELECT id, Hex, Rgb, Position from Colours ORDER BY Position ASC")
My PopulateColours method contains the following code:
[code]// CLEAR THE LISTBOX
Listbox2.deleteAllRows
// RETURN THE RESULTS AS A RECORDSET
rs=db2.sqlSelect(sql )
// POPULATE THE COLOURS LISTBOX
while not rs.eof
Listbox2.AddRow
Listbox2.Cell(Listbox2.LastIndex, 1) = rs.Field(“Hex”).StringValue
Listbox2.Cell(Listbox2.LastIndex, 2) = rs.Field(“Rgb”).StringValue
Listbox2.RowTag(Listbox2.LastIndex) = rs.Field(“id”).IntegerValue
rs.moveNext
wend[/code]
Then, when I have entered the colour values into my textfield, I press the save button which calls a method called PrepareAndInsertColours.
It contains the following code:
[code]// SET THE VARIABLE VALUES
FinalHexadecimal = ("&c" + Hex1Field.text + Hex2Field.text + Hex3Field.text)
FinalRgb = “RGB(” + RField.text +"," + GField.text + “,” + BField.text + “)”
// PREPARE THE STATEMENT
Dim ps As SQLitePreparedStatement = db.Prepare(“INSERT INTO Colours (Hex, Rgb) VALUES (?, ?);”)
// BIND THE TEXT FIELD VALUES
ps.BindType(0, SQLitePreparedStatement.SQLITE_TEXT)
ps.BindType(1, SQLitePreparedStatement.SQLITE_TEXT)
ps.Bind(0, FinalHexadecimal)
ps.Bind(1, FinalRgb)
// INSERT THE VALUES INTO THE DATABASE
ps.SQLExecute
// CHECK FOR DATABASE ERROR
If db.Error Then
MsgBox("Error: " + Str(db.ErrorCode) + " - " + db.ErrorMessage)
Return
Else
// UPDATE THE LISTBOX
PopulateColours(Listbox2,db,“select id, Hex, Rgb, Position from Colours order by Position Asc”)
// CLOSE THE WINDOW
Self.Close
end if[/code]
Does this look right, so far?
I believe the position column may give me problems here??
This is where I get lost