Conversion failed from nvarchar to int in a SQL query

I am trying to run a SQL query to delete an item from a database. I have created a memory tag as type Integer. When I run the query I get an error that it failed to convert nvarchar to int. The memory tag is int and the column in the database is int. What am I doing wrong?

Script looks like this:

boxnum = “BoxNumForRemoval”

If boxnum is not None:
confirm = system.gui.confirm(“Are you sure to remove box %s ?” % boxnum, “Remove Box”)
if confirm:
server = “SQLServer_New”
txID = system.db.beginTransaction(server)

      query = "DELETE FROM BoxLabelData WHERE BoxNumber >= ?"
      args = [boxnum]
      system.db.runPrepUpdate (query, args, server, tx = txID)

      system.db.commitTransaction(txID)
      system.db.closeTransaction(txID)
 else:
      system.gui.messageBox("No Box Selected", "Invalid Selection")

Never mind. I figured it out. It’s tough being in china with no internet connection to be able to use the help.

1 Like

What was the solution?

I got rid of the tags and bound directly to the properties of the number field.

1 Like