Android Question Syntax Error in INSERT query. Please Help!

Rajesh Gupta

Member
Licensed User
B4X:
Dim query As String= "INSERT into tblLogin VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?) WHERE BDEPID = '"& GlobalConst.BDEPID &"' AND CONNECTION_TYPE = 0"
                    SQL1.ExecNonQuery2(query,Array As String(GlobalConst.BDEPID, GlobalConst.UID, GlobalConst.BUSYId, GlobalConst.BUSYPwd, GlobalConst.SELECT_MODE, DateTime.Date(DateTime.now), GlobalConst.CONNECTION_TYPE, 0, 0, GlobalConst.CompName, GlobalConst.CurFY, GlobalConst.EndFY, GlobalConst.Mode, GlobalConst.CurSymbol))
 

DonManfred

Expert
Licensed User
What is the full error? We can not guess it
Additionally you are not using parametrized parameters correctly.

B4X:
Dim query As String= "INSERT into tblLogin VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?) WHERE BDEPID = ? AND CONNECTION_TYPE = ?"
                    SQL1.ExecNonQuery2(query,Array As String(GlobalConst.BDEPID, GlobalConst.UID, GlobalConst.BUSYId, GlobalConst.BUSYPwd, GlobalConst.SELECT_MODE, DateTime.Date(DateTime.now), GlobalConst.CONNECTION_TYPE, 0, 0, GlobalConst.CompName, GlobalConst.CurFY, GlobalConst.EndFY, GlobalConst.Mode, GlobalConst.CurSymbol, GlobalConst.BDEPID, 0))
 
Upvote 0

Rajesh Gupta

Member
Licensed User
(query,Array As String(GlobalConst.BDEPID, GlobalC

This the full error:-

android.database.sqlite.SQLiteException: near "WHERE": syntax error (code 1): , while compiling: INSERT into tblLogin VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?) WHERE BDEPID = ? AND CONNECTION_TYPE = ?
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:887)
at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:498)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31)
at android.database.sqlite.SQLiteDatabase.compileStatement(SQLiteDatabase.java:994)
at anywheresoftware.b4a.sql.SQL.ExecNonQuery2(SQL.java:85)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:778)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:358)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.BA$2.run(BA.java:365)
at android.os.Handler.handleCallback(Handler.java:742)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5603)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:774)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:652)
What is the full error? We can not guess it
Additionally you are not using parametrized parameters correctly.

B4X:
Dim query As String= "INSERT into tblLogin VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?) WHERE BDEPID = ? AND CONNECTION_TYPE = ?"
                    SQL1.ExecNonQuery2(query,Array As String(GlobalConst.BDEPID, GlobalConst.UID, GlobalConst.BUSYId, GlobalConst.BUSYPwd, GlobalConst.SELECT_MODE, DateTime.Date(DateTime.now), GlobalConst.CONNECTION_TYPE, 0, 0, GlobalConst.CompName, GlobalConst.CurFY, GlobalConst.EndFY, GlobalConst.Mode, GlobalConst.CurSymbol, GlobalConst.BDEPID, 0))
 
Upvote 0
Top