# Store Image into SQL 2008

**URL:** <https://forum.inductiveautomation.com/t/store-image-into-sql-2008/11895>\
**Category:** Ignition\
**Created:** [July 6, 2016, 12:25am UTC](https://forum.inductiveautomation.com/t/store-image-into-sql-2008/11895 "2016-07-06T00:25:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jado58](https://avatars.discourse-cdn.com/v4/letter/j/cdc98d/32.png) [@Jado58](https://forum.inductiveautomation.com/u/Jado58)\
**Post date:** [July 6, 2016, 12:25am UTC](https://forum.inductiveautomation.com/t/store-image-into-sql-2008/11895/1 "2016-07-06T00:25:34Z")

</div>

I’m having an issue saving images to the sql 2008, I get an The index 2 is out of range error, my table has 2 columns ndx INT and image VARBINARY(max)  
below is the code I’m using, I have also attached the error code.

`path = system.file.openFile()
if path != None:
   bytes = system.file.readFileAsBytes(path)
   system.db.runPrepUpdate(" INSERT INTO JDEPARTIMG (ndx,image) Values(10,Cast(? as varbinary(max))",(bytes))`

---

<div class="post-metadata">

**Author:** ![jpark](https://avatars.discourse-cdn.com/v4/letter/j/a88e57/32.png) [@jpark](https://forum.inductiveautomation.com/u/jpark)\
**Post date:** [July 6, 2016, 2:57am UTC](https://forum.inductiveautomation.com/t/store-image-into-sql-2008/11895/2 "2016-07-06T02:57:51Z")

</div>

`path = system.file.openFile()
if path != None:
   bytes = system.file.readFileAsBytes(path)
   system.db.runPrepUpdate(" INSERT INTO JDEPARTIMG (ndx,image) Values(10,?)",[bytes])`

---

<div class="post-metadata">

**Author:** ![Jado58](https://avatars.discourse-cdn.com/v4/letter/j/cdc98d/32.png) [@Jado58](https://forum.inductiveautomation.com/u/Jado58)\
**Post date:** [July 6, 2016, 12:39pm UTC](https://forum.inductiveautomation.com/t/store-image-into-sql-2008/11895/3 "2016-07-06T12:39:37Z")

</div>

Thank you!, I did’t notice the square brackets in the other thread, the manual has parenthesis?  
what would be the best way to display the image in an image component?
