I cant seem to get this right so I am asking what am I overlooking in my code. here’s what I’ve got in my code:
newLeaseData = "INSERT INTO " + enterLogLN + " (Date, "
+ "StockTank1Ft, StockTank1Inch, StockTank2Ft, StockTank2Inch, "
+ "StockTank3Ft, StockTank3Inch, StockTank4Ft, StockTank4Inch, "
+ "Change1, Change2, Change3, Change4) VALUES "
+ "(" + today + ", '" + valueT1Ft + "', '" + valueT1Inch + "', '" + valueT2Ft
+ "', '" + valueT2Inch + "', '" + valueT3Ft + "', '" + valueT3Inch
+ "', '" + valueT4Ft + "', '" + valueT4Inch + "', " + difTotalT1
+ ", " + difTotalT2 + ", " + difTotalT3 + ", " + difTotalT4 + ")";
everything works until I get to strings: difTotalT1, difTotalT2, difTotalT3 and difTotalT4.
each string is set to something like: 0′-1″ , 0′-2″ , 0′-3″ or 0′-4″
and when I try to exec the command:
myDataBase.execSQL(EnterLogDataOilActivity.newLeaseData);
my app crashes with this logcat error:
06-05 04:36:23.824: E/AndroidRuntime(1127): android.database.sqlite.SQLiteException: near “‘-1″, 0′”: syntax error: INSERT INTO about (Date, StockTank1Ft, StockTank1Inch, StockTank2Ft, StockTank2Inch, StockTank3Ft, StockTank3Inch, StockTank4Ft, StockTank4Inch, Change1, Change2, Change3, Change4) VALUES (’05_05_12’, ‘0’, ‘1’, ‘0’, ‘2’, ‘0’, ‘3’, ‘0’, ‘4’, 0′-1″, 0′-2″, 0′-3″, 0′-4″)
thanks for the help I know it has got to be something simple. I have also tried inclosing each difTotalT1 string with a single quote but that does not work either (ie difTotalT1 = “‘” + difTotalT1 + “‘”;)
this is the string I used to create the table in sqlite:
newLeaseTable = "create table '" + leaseName + "' (_id integer primary key autoincrement,"
+ " Date TEXT, StockTank1Ft NUMERIC, StockTank1Inch NUMERIC,"
+ " StockTank2Ft NUMERIC, StockTank2Inch NUMERIC, StockTank3Ft NUMERIC,"
+ " StockTank3Inch NUMERIC, StockTank4Ft NUMERIC, StockTank4Inch NUMERIC,"
+ " Change1 TEXT, Change2 TEXT, Change3 TEXT, Change4 TEXT, User TEXT);";
I couldn’t get it to work so I changed my var from a string to an int and then set it up so it would display it differently. thanks for your help