Block group: Must declare the variable "@1"

Hey all, I just helped out someone who was having this problem, and thought it would be good to put up here:

Using block groups with MS SQL Server, they were getting the error “Must declare variable @1”.

The trick here is that they were using an ODBC connection instead of the native driver. Turns out the ODBC driver expects the more standard ‘?’ format for parameters (which the block groups use a lot). To fix this you have to modify the database definition file for SQL Server:

  1. Open SQLServer.xml in Program Files\Inductive Automation\FactorySQL\database with notepad.
  2. Change the ParameterChar property from @ to ?
  3. Change UseNamedParameters from true to false
  4. Save, restart FactorySQL service (make sure to restart the actual service, through the service control panel, and not just the tray app).

You should now be good to go! Feel free to post here if there are any other problems.