I could use some direction on how to accomplish something with a B4XTable. I would guess it would work by always reloading the entire table, but I would expect to be able to do it within B4XTable.
I have a B4XTable with something in it (1 column, some rows of values).
I want to add expand it by adding another column to B4XTable1, and then add a row with values in (both) columns.
If I use the following Sub, it fails to add the field ((SQLException) java.sql.SQLException: [SQLITE_ERROR] SQL error or missing database (near "770756": syntax error)).
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
If I use AddColumn, when I try to add a row it complains trying to insert 2 columns into a table with 1 column.
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
If I try the .AddColumn approach, and add a .RefreshNow (to hopefully force the table to realize the added column), RefreshNow gives exception
java.sql.SQLException: [SQLITE_ERROR] SQL error or missing database (near "FROM": syntax error)
Thank you.
			
			I have a B4XTable with something in it (1 column, some rows of values).
I want to add expand it by adding another column to B4XTable1, and then add a row with values in (both) columns.
If I use the following Sub, it fails to add the field ((SQLException) java.sql.SQLException: [SQLITE_ERROR] SQL error or missing database (near "770756": syntax error)).
			
				B4X:
			
		
		
		Sub AddColumn(sID As String) ' say sID="770756"
    Dim query As String
    query = "ALTER TABLE DATA ADD COLUMN "&sID&" text"
    B4XTable1.SQL1.BeginTransaction
    Try
        B4XTable1.SQL1.ExecNonQuery(query)
        B4XTable1.SQL1.TransactionSuccessful   '*****************************************************
    Catch
        Log("failed to Add "&sID&" Field")
  
    End Try
    'B4XTable1.SQL1.EndTransaction
End SubIf I use AddColumn, when I try to add a row it complains trying to insert 2 columns into a table with 1 column.
			
				B4X:
			
		
		
		B4XTable1.AddColumn(PN,  B4XTable1.COLUMN_TYPE_TEXT)
			
				B4X:
			
		
		
		Try
    Dim lCells As List
    lCells.Add("a")
    lCells.Add("b")
    B4XTable1.sql1.ExecNonQuery2($"INSERT INTO data VALUES(?,?")"$, lCells)
    B4XTable1.Refresh
Catch
    Log(LastException) ' java.sql.SQLException: [SQLITE_ERROR] SQL error or missing database (table data has 1 columns but 2 values were supplied)
End TryIf I try the .AddColumn approach, and add a .RefreshNow (to hopefully force the table to realize the added column), RefreshNow gives exception
java.sql.SQLException: [SQLITE_ERROR] SQL error or missing database (near "FROM": syntax error)
Thank you.
			
				Last edited: 
			
		
	
								
								
									
	
								
							
							 
				 
 
		 
 
		 
 
		 
 
		