# Comments panel database

**URL:** <https://forum.inductiveautomation.com/t/comments-panel-database/2292>\
**Category:** Ignition\
**Created:** [October 22, 2010, 5:20pm UTC](https://forum.inductiveautomation.com/t/comments-panel-database/2292 "2010-10-22T17:20:57Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![scott\_stc](https://avatars.discourse-cdn.com/v4/letter/s/d26b3c/32.png) [@scott\_stc](https://forum.inductiveautomation.com/u/scott_stc)\
**Post date:** [October 22, 2010, 5:20pm UTC](https://forum.inductiveautomation.com/t/comments-panel-database/2292/1 "2010-10-22T17:20:57Z")

</div>

Hello,

We are trying to get the comments panel working, but are having trouble with errors everytime the screen is run. We are using a MySQL DB. We’re under the assumption that the table is not automatically created (like in the transactions groups), so we created one, but errors saying: GatewayException: Gateway Error 301: SQL error for “INSERT INTO Notes (Note, WhoId, TStamp, Attachment, Filename, Sticky) VALUES (?, (SELECT Id FROM Users WHERE Username=‘admin’), CURRENT\_TIMESTAMP, ?, ?, ?)”: Table ‘test.users’ doesn’t exist  
caused by MySQLSyntaxErrorException: Table ‘test.users’ doesn’t exist

Can you tell me what we’re doing wrong?

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [October 22, 2010, 5:25pm UTC](https://forum.inductiveautomation.com/t/comments-panel-database/2292/2 "2010-10-22T17:25:41Z")

</div>

Sure, the insert query property of the comments panel is set to the following:`INSERT INTO Notes (Note, WhoId, TStamp, Attachment, Filename, Sticky) VALUES (?, (SELECT Id FROM Users WHERE Username='admin'), CURRENT_TIMESTAMP, ?, ?, ?)`In that example the notes table has a user id not a username, so there is a sub-query that looks up the user id based on the username. If you just need the username change the query to the following:`INSERT INTO Notes (Note, WhoId, TStamp, Attachment, Filename, Sticky) VALUES (?, '%s', CURRENT_TIMESTAMP, ?, ?, ?)`This also means youur notes table must have the following fields:

Note  
WhoId  
TStamp  
Attachment  
Filename  
Sticky

If the columns do not match change the query so they do. Hope this helps.

---

<div class="post-metadata">

**Author:** ![MCC](https://avatars.discourse-cdn.com/v4/letter/m/3e96dc/32.png) [@MCC](https://forum.inductiveautomation.com/u/MCC)\
**Post date:** [March 23, 2011, 12:22am UTC](https://forum.inductiveautomation.com/t/comments-panel-database/2292/3 "2011-03-23T00:22:09Z")

</div>

I am trying to set this up and running into what may be a similar problem.  
I have my two tables set up and I can enter data into SQL Server and the notes entered directly into the tables show up fine in the comments panel. However, the add, unstick and delete buttons in the comments panel do not work. I debugged my query strings and they seem OK, but I am getting an error that the “Notes” object doesn’t exist:  
GatewayException: Gateway Error 301: SQL error for “INSERT INTO Notes (Note, UserName, Timestamp, Attachment, AttachmentFilename, Stick) VALUES (?, ‘admin’, CURRENT\_TIMESTAMP, ?, ?, ?)”: Invalid object name ‘Notes’.  
caused by SQLServerException: Invalid object name ‘Notes’.

I am wondering where you set up the database connection that is used by these queries. I can set it for the query that generates the data set, but I don’t see anywhere to set it for the insert, update and delete queries. Do they automatically use the same connection? I think they may be defaulting to a database that doesn’t exist or doesn’t contain my notes table.

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [March 23, 2011, 5:25pm UTC](https://forum.inductiveautomation.com/t/comments-panel-database/2292/4 "2011-03-23T17:25:27Z")

</div>

You are right, we are using the default database connection for the project for the insert and update queries. I will add a ticket to add a datasource property to the component.

---

<div class="post-metadata">

**Author:** ![MCC](https://avatars.discourse-cdn.com/v4/letter/m/3e96dc/32.png) [@MCC](https://forum.inductiveautomation.com/u/MCC)\
**Post date:** [March 23, 2011, 6:18pm UTC](https://forum.inductiveautomation.com/t/comments-panel-database/2292/5 "2011-03-23T18:18:42Z")

</div>

I just tried using it with the default data source and it almost worked.  
SQL server is rejecting the attachment. I have that column set up as a varbinary(max), which I think should correspond to a BLOB. I tried putting a convert statement into the insert query, but it didn’t like the syntax.  
Any tips on getting this to work with SQL Server?

My original insert:  
[color=#0000FF]INSERT INTO Notes (NoteText, UserName, Timestamp, Attachment, AttachmentFilename, Stick) VALUES (?, ‘%s’, CURRENT\_TIMESTAMP, ?, ?, ?)[/color]  
Gives this error:  
[color=#FF0000]GatewayException: Gateway Error 301: SQL error for “INSERT INTO Notes (NoteText, UserName, Timestamp, Attachment, AttachmentFilename, Stick) VALUES (?, ‘admin’, CURRENT\_TIMESTAMP, ?, ?, ?)”: Implicit conversion from data type varchar to varbinary(max) is not allowed. Use the CONVERT function to run this query.  
caused by SQLServerException: Implicit conversion from data type varchar to varbinary(max) is not allowed. Use the CONVERT function to run this query.

Ignition v7.2.5-beta3 (b63)  
Java: Sun Microsystems Inc. 1.6.0\_24[/color]

Then I tried this insert:  
[color=#0000FF]INSERT INTO Notes (NoteText, UserName, Timestamp, Attachment, AttachmentFilename, Stick) VALUES (?, ‘%s’, CURRENT\_TIMESTAMP, (CONVERT(varbinary(MAX),?), ?, ?)[/color]  
which caused a syntax error.

Attachments aren’t really required in this application. Is there a way to turn that feature off so I don’t have to worry about it in the queries?

Thanks.

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [March 23, 2011, 8:41pm UTC](https://forum.inductiveautomation.com/t/comments-panel-database/2292/6 "2011-03-23T20:41:33Z")

</div>

You do need to convert the data type. Just do the following:

INSERT INTO Notes (NoteText, UserName, Timestamp, Attachment, AttachmentFilename, Stick) VALUES (?, ‘%s’, CURRENT\_TIMESTAMP, CAST(? AS varbinary(MAX)), ?, ?)

That should work!

---

<div class="post-metadata">

**Author:** ![MCC](https://avatars.discourse-cdn.com/v4/letter/m/3e96dc/32.png) [@MCC](https://forum.inductiveautomation.com/u/MCC)\
**Post date:** [March 23, 2011, 10:12pm UTC](https://forum.inductiveautomation.com/t/comments-panel-database/2292/7 "2011-03-23T22:12:00Z")

</div>

That does the trick! Thanks a bunch.
