# Inserting Signature byteStream to Database

**URL:** <https://forum.inductiveautomation.com/t/inserting-signature-bytestream-to-database/86812>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [March 5, 2024, 9:15am UTC](https://forum.inductiveautomation.com/t/inserting-signature-bytestream-to-database/86812 "2024-03-05T09:15:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aron\_Grzywaczewski](https://avatars.discourse-cdn.com/v4/letter/a/439d5e/32.png) [@Aron\_Grzywaczewski](https://forum.inductiveautomation.com/u/Aron_Grzywaczewski)\
**Post date:** [March 5, 2024, 9:15am UTC](https://forum.inductiveautomation.com/t/inserting-signature-bytestream-to-database/86812/1 "2024-03-05T09:15:49Z")

</div>

Hello,

I'm trying to insert the signature bytestream into the database from the SignaturePad perspective component.  
Unfortunately, I'm getting an error message. Please can anyone help? Here is my code:

```auto
mySignature = event.signatureFile.getBytes()

query = "INSERT INTO PhotoTable (photo) VALUES (?)"
args = [mySignature]
system.db.runPrepUpdate(query, args, "MyDBConn")

```

This is my table definition:

```auto
CREATE TABLE [dbo].[PhotoTable](
	[Id] [bigint] IDENTITY(1,1) NOT NULL,
	[photo] [varbinary](50) NULL
) ON [PRIMARY]
GO

```

and here is the error that I'm getting:

```auto
com.inductiveautomation.ignition.common.script.JythonExecException: Traceback (most recent call last): File "", line 7, in runAction at com.inductiveautomation.ignition.common.script.builtin.AbstractDBUtilities.error(AbstractDBUtilities.java:392) at com.inductiveautomation.ignition.common.script.builtin.AbstractDBUtilities.runPrepUpdate(AbstractDBUtilities.java:268) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) java.lang.Exception: java.lang.Exception: Error executing system.db.runPrepUpdate(INSERT INTO PhotoTable (photo) VALUES (?), [[B@2e6e5744], UNILEVERAQUILA, , false, false)

at org.python.core.Py.JavaError(Py.java:545)

at com.inductiveautomation.ignition.common.script.builtin.AbstractDBUtilities.error(AbstractDBUtilities.java:392)

at com.inductiveautomation.ignition.common.script.builtin.AbstractDBUtilities.runPrepUpdate(AbstractDBUtilities.java:268)

at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.base/java.lang.reflect.Method.invoke(Unknown Source)

at org.python.core.PyReflectedFunction. __call__ (PyReflectedFunction.java:190)

at com.inductiveautomation.ignition.common.script.ScriptManager$ReflectedInstanceFunction. __call__ (ScriptManager.java:553)

at org.python.core.PyObject. __call__ (PyObject.java:494)

at org.python.core.PyObject. __call__ (PyObject.java:498)

at org.python.pycode._pyx2024.runAction$1(:7)

at org.python.pycode._pyx2024.call_function()

at org.python.core.PyTableCode.call(PyTableCode.java:173)

at org.python.core.PyBaseCode.call(PyBaseCode.java:306)

at org.python.core.PyFunction.function ___call__ (PyFunction.java:474)

at org.python.core.PyFunction. __call__ (PyFunction.java:469)

at org.python.core.PyFunction. __call__ (PyFunction.java:464)

at com.inductiveautomation.ignition.common.script.ScriptManager.runFunction(ScriptManager.java:847)

at com.inductiveautomation.ignition.common.script.ScriptManager.runFunction(ScriptManager.java:829)

at com.inductiveautomation.ignition.gateway.project.ProjectScriptLifecycle$TrackingProjectScriptManager.runFunction(ProjectScriptLifecycle.java:868)

at com.inductiveautomation.ignition.common.script.ScriptManager$ScriptFunctionImpl.invoke(ScriptManager.java:1010)

at com.inductiveautomation.ignition.gateway.project.ProjectScriptLifecycle$AutoRecompilingScriptFunction.invoke(ProjectScriptLifecycle.java:950)

at com.inductiveautomation.perspective.gateway.script.ScriptFunctionHelper.invoke(ScriptFunctionHelper.java:161)

at com.inductiveautomation.perspective.gateway.script.ScriptFunctionHelper.invoke(ScriptFunctionHelper.java:98)

at com.inductiveautomation.perspective.gateway.action.ScriptAction.runAction(ScriptAction.java:80)

at com.inductiveautomation.perspective.gateway.model.ActionCollection$ActionSequence$ExecuteActionsTask.lambda$call$0(ActionCollection.java:263)

at com.inductiveautomation.perspective.gateway.api.LoggingContext.mdc(LoggingContext.java:54)

at com.inductiveautomation.perspective.gateway.model.ActionCollection$ActionSequence$ExecuteActionsTask.call(ActionCollection.java:252)

at com.inductiveautomation.perspective.gateway.model.ActionCollection$ActionSequence$ExecuteActionsTask.call(ActionCollection.java:221)

at com.inductiveautomation.perspective.gateway.threading.BlockingTaskQueue$TaskWrapper.run(BlockingTaskQueue.java:154)

at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)

at java.base/java.util.concurrent.FutureTask.run(Unknown Source)

at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

at com.inductiveautomation.perspective.gateway.threading.BlockingWork$BlockingWorkRunnable.run(BlockingWork.java:58)

at java.base/java.lang.Thread.run(Unknown Source)

Caused by: org.python.core.PyException: java.lang.Exception: java.lang.Exception: Error executing system.db.runPrepUpdate(INSERT INTO PhotoTable (photo) VALUES (?), [[B@2e6e5744], UNILEVERAQUILA, , false, false)

... 37 common frames omitted

Caused by: java.lang.Exception: Error executing system.db.runPrepUpdate(INSERT INTO PhotoTable (photo) VALUES (?), [[B@2e6e5744], UNILEVERAQUILA, , false, false)

... 36 common frames omitted

Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: String or binary data would be truncated.

at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:265)

at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1662)

at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:615)

at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:537)

at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7417)

at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:3488)

at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:262)

at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:237)

at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeUpdate(SQLServerPreparedStatement.java:483)

at org.apache.commons.dbcp2.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:136)

at org.apache.commons.dbcp2.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:136)

at com.inductiveautomation.ignition.gateway.datasource.SRConnectionWrapper$SRPreparedStatement.executeUpdate(SRConnectionWrapper.java:981)

at com.inductiveautomation.ignition.gateway.datasource.SRConnectionWrapper.runPrepUpdate(SRConnectionWrapper.java:181)

at com.inductiveautomation.ignition.gateway.script.GatewayDBUtilities._runPrepStmt(GatewayDBUtilities.java:203)

at com.inductiveautomation.ignition.common.script.builtin.AbstractDBUtilities.runPrepUpdate(AbstractDBUtilities.java:261)

... 34 common frames omitted

```

---

<div class="post-metadata">

**Author:** ![Hayden\_Watson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/hayden_watson/32/48792_2.png) [@Hayden\_Watson](https://forum.inductiveautomation.com/u/Hayden_Watson)\
**Post date:** [March 5, 2024, 9:20am UTC](https://forum.inductiveautomation.com/t/inserting-signature-bytestream-to-database/86812/2 "2024-03-05T09:20:04Z")

</div>

Getting some error on the prep update. I would make this as a named query and test with some dummy data if it inserts properly.

---

<div class="post-metadata">

**Author:** ![Aron\_Grzywaczewski](https://avatars.discourse-cdn.com/v4/letter/a/439d5e/32.png) [@Aron\_Grzywaczewski](https://forum.inductiveautomation.com/u/Aron_Grzywaczewski)\
**Post date:** [March 5, 2024, 9:22am UTC](https://forum.inductiveautomation.com/t/inserting-signature-bytestream-to-database/86812/3 "2024-03-05T09:22:24Z")

</div>

I tried inserting just value of 0 with the same query and it worked.

I suspect that there is something wrong with the datatype of the "mySignature" variable

---

<div class="post-metadata">

**Author:** ![Aron\_Grzywaczewski](https://avatars.discourse-cdn.com/v4/letter/a/439d5e/32.png) [@Aron\_Grzywaczewski](https://forum.inductiveautomation.com/u/Aron_Grzywaczewski)\
**Post date:** [March 5, 2024, 9:42am UTC](https://forum.inductiveautomation.com/t/inserting-signature-bytestream-to-database/86812/4 "2024-03-05T09:42:44Z")

</div>

ok, it's now resolved.

I had to increase the size in database
