# Problem running RunPrepQuery with string args

**URL:** <https://forum.inductiveautomation.com/t/problem-running-runprepquery-with-string-args/82675>\
**Category:** Ignition\
**Created:** [December 4, 2023, 5:30pm UTC](https://forum.inductiveautomation.com/t/problem-running-runprepquery-with-string-args/82675 "2023-12-04T17:30:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Roger\_Denison](https://avatars.discourse-cdn.com/v4/letter/r/e19b73/32.png) [@Roger\_Denison](https://forum.inductiveautomation.com/u/Roger_Denison)\
**Post date:** [December 4, 2023, 5:30pm UTC](https://forum.inductiveautomation.com/t/problem-running-runprepquery-with-string-args/82675/1 "2023-12-04T17:30:19Z")

</div>

I'm trying to use RunPrepQuery in a script and I keep getting an error: "Index 1 is out of range"

Here's the line:  
table = system.db.runPrepQuery("SELECT \* FROM tblDummy WHERE [Column1] = '?' AND [Column2] = '?'", [string1, string2])

Where string1 is 'First' and string2 is 'Second'.

The error details show:  
"Error executing system.db.runPrepQuery(SELECT \* FROM tblDummy WHERE [Column1] = '?' AND [Column2] = '?', , [First, Second], )"

I've tried both '=' and 'LIKE' but still get the same error. As you can see in the details, my args are after the 2nd set of commas, not the first, where they should be.

What am I missing in my script?

---

<div class="post-metadata">

**Author:** ![code\_skin](https://avatars.discourse-cdn.com/v4/letter/c/43a26b/32.png) [@code\_skin](https://forum.inductiveautomation.com/u/code_skin)\
**Post date:** [December 4, 2023, 5:31pm UTC](https://forum.inductiveautomation.com/t/problem-running-runprepquery-with-string-args/82675/2 "2023-12-04T17:31:38Z")

</div>

remove the quotes around the ?'s. runPrepQuery will handle datatype comparisons.

---

<div class="post-metadata">

**Author:** ![Roger\_Denison](https://avatars.discourse-cdn.com/v4/letter/r/e19b73/32.png) [@Roger\_Denison](https://forum.inductiveautomation.com/u/Roger_Denison)\
**Post date:** [December 4, 2023, 5:46pm UTC](https://forum.inductiveautomation.com/t/problem-running-runprepquery-with-string-args/82675/3 "2023-12-04T17:46:19Z")

</div>

Sweet! Thank you!
