Dynamic Prepared Statements

I have a method that needs to either insert or update a record in a table…
the problem is the “table” is of an unknown structure…
Obviously I can determine all the required information … and “build” the prepared statment and bindings

//
// Build Prepared SQL Statement
//
If globalRowID<0 Then 
   SQL="Insert into "+globalString+" Values("
Else
   SQL="Update "+GlobalString+" SET "
End If
//
For i=0 To field_name.Ubound-1
   If globalRowID<0 Then 
      SQL=SQL+"?"
   Else
      SQL=SQL+field_name(i)+"=?"
   End If
   If i<field_name.Ubound-1 Then SQL=SQL+","
Next i
If globalRowID<0 Then 
   SQL=SQL+")"
Else
   SQL=SQL+" WHERE rowid="+Str(globalRowID)
End If
//
ps = db.prepare(SQL)
//
For i=0 To field_name.Ubound-1
   select case field_datatype(i)
     case dataIsNULL
        kind=SQLitePreparedStatement.SQLITE_NULL
     case dataIsTEXT,dataIsDATE,dataIsTIME,dataIsTIMESTAMP
        kind=SQLitePreparedStatement.SQLITE_TEXT
     case dataIsINTEGER
        kind=SQLitePreparedStatement.SQLITE_INTEGER
     case dataIsDOUBLE
        kind=SQLitePreparedStatement.SQLITE_DOUBLE
     case dataIsBOOLEAN
        kind=SQLitePreparedStatement.SQLITE_BOOLEAN
     case dataIsBLOB
        kind=SQLitePreparedStatement.SQLITE_BLOB
     case else
        kind=SQLitePreparedStatement.SQLITE_TEXT
   end select
   ps.BindType(i,kind) 
next i

// WHAT GOES HERE?  
// the data is in field_data() ..... the prepared statement is in PS
// but the ubound of field_data will vary from table to table and never be known at design time
ps.BindType(i, SQLitePreparedStatement.SQLITE_TEXT)
ps.Bind(i, field_data(i))

I think you mean

ps.BindType(i, kind) ps.Bind(i, field_data(i))