I am trying to learn how to use the SQL server connection. I will be doing many different queries so I am trying to learn how to query via code. I have SQL Server, and was successfully able to set it up in the Database Connector: the Test Connection button returned "Connection succeeded" and I was able to use the import tab to get the data into a global table.
But as I said I wanted to do it by code. So I put the code below in a ProcessFlow Custom Code activity, but got this error:
"time: 0.000000 exception: FlexScript exception: 42000 [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Statement(s) could not be prepared. at MODEL:/Tools/ProcessFlow/ProcessFlow/Custom Code>variables/codeNode"
/**Custom Code*/ Object current = param(1); treenode activity = param(2); Token token = param(3); treenode processFlow = ownerobject(activity); Database.Connection dbConnection_1 = Database.Connection("DBConnector1"); // Make sure it's connected if(dbConnection_1.isConnected == 0) { dbConnection_1.connect(); } // Confirm that it was successful if(dbConnection_1.isConnected == 0) { print("Not connected"); } else { print("Connected"); } // Get the data from the SQL database Database.ResultSet queryResult = dbConnection_1.query("SELECT * FROM TestDataForFlexSimConnection"); // Echo the data to confirm while(queryResult.fetchNext()) { print(queryResult["TestCol1"], " ", queryResult["TestCol2"], " ", queryResult["TestCol3"]); }