Hello I have a program that is working, I had a customer ask if I could add a notes section to my program, great idea. I added the following code :
private var insertStmt:SQLStatement;
private function updateTable():void
{
insertStmt = new SQLStatement();
insertStmt.sqlConnection = conn;
var sql:String = "";
sql += "ALTER TABLE Customersold ADD Note TEXT;";
insertStmt.text = sql;
insertStmt.execute();
that runs fine if the customer is using this version for the first time, but after running it a 2nd time i get an error that the column already exists. How can i fix this?
conn btw is my sql connection.
Edit: This is a program not a mobil app.
Don't run the statement twice. If you ask SQLLite to add a column that is already there, then throwing an error is the expected behaviour.
If you end up with update scripts in your app like this (which is not uncommon) then the usual way to deal with it is to store a version number in your DB and apply upgrades incrementally as needed. As you haven't done that yet, you can also assume that if no version number was present then it's version 1. Just check this somewhere when your app starts up.
Pseudo code:
Then just update functions similar to as you have now.
You get to flesh out the functions yourself.