I created a database with Filestream activated, and I created a “pdfs” table inside of that the database which has the following columns (Name,Address,Date,File) and I am trying to use the file uploader in perspective to upload a pdf file to the table. The code is:
filename = event.file.name
fileBytes = event.file.getBytes()
system.db.runPrepUpdate(
"INSERT INTO pdfs (Name,Address,Date,File) VALUES (?,?,?,?)",
[filename,'Files',system.date.now(),fileBytes],'QualityFiles')
self.getSibling("Table").refreshBinding("props.data")
The error is:
com.inductiveautomation.ignition.common.script.JythonExecException
Traceback (most recent call last):
File "<function:runAction>", line 7, in runAction
java.lang.Exception: java.lang.Exception: Error executing system.db.runPrepUpdate(INSERT INTO pdfs (Name,Address,Date,File) VALUES (?,?,?,?), [8C400216 Packaging Instructions.pdf, Files, Fri Apr 09 17:25:31 EDT 2021, [B@627e6452], QualityFiles, , false, false)
caused by org.python.core.PyException
Traceback (most recent call last):
File "<function:runAction>", line 7, in runAction
java.lang.Exception: java.lang.Exception: Error executing system.db.runPrepUpdate(INSERT INTO pdfs (Name,Address,Date,File) VALUES (?,?,?,?), [8C400216 Packaging Instructions.pdf, Files, Fri Apr 09 17:25:31 EDT 2021, [B@627e6452], QualityFiles, , false, false)
caused by Exception: Error executing system.db.runPrepUpdate(INSERT INTO pdfs (Name,Address,Date,File) VALUES (?,?,?,?), [8C400216 Packaging Instructions.pdf, Files, Fri Apr 09 17:25:31 EDT 2021, [B@627e6452], QualityFiles, , false, false)
caused by SQLServerException: Incorrect syntax near the keyword 'File'.
Ignition v8.1.4 (b2021040109)
Java: Azul Systems, Inc. 11.0.9