Android Question How to convert SQL statements in B4A?

bskotu555

Active Member
'cx' and 'zw' are text variables:
strSQL ="SELECT * FROM smt where cxnm='" & cx & "' and zwnm='" & zw & "'"
Cursor = Starter.Mysql_Jdbc.ExecQuery(strSQL)
 

aeric

Expert
Licensed User
Longtime User
View attachment 158030
I put these two sentences into the program, but it just reported an error. What's the situation?
If your column names are English word without blank spaces, then you don't need to escape them with back ticks.
Just write like this will do:
B4X:
Dim strSQL As String = "SELECT * FROM smt WHERE cxnm = ? AND zwnm = ?"
 
Upvote 0

walt61

Well-Known Member
Licensed User
Longtime User
If your column names are English word without blank spaces, then you don't need to escape them with back ticks.
You are of course absolutely right. I make it a habit of using backticks for column and table names: then, I don't have to worry about them being reserved words or containing special characters.
 
Upvote 0
Top