Returns a SqlDataReader resulting from the execution of the given SQL query statement sqlStatement.
A SqlDataReader object for reading the results of the SQL query.
This method provides the ability to perform SQL Select queries against the SQL Server hosting DatStat Illume. The added benefit of this method is that it will use the existing DatStat Illume Collector connection pool alleviating the need for the developer to get a connection. The SqlDataReader returned by this method should be closed by the developer. However, stale SqlDataReaders will always be closed on subsequent calls to this method. The important side-effect of this is that only a single SqlDataReader provided by a call to this method can be used at a time. For example the following code would not work:
SqlDataReader reader1 = ctx.ExecSQLWithResults(“select fname, lname from table1”);
SqlDataReader reader2 = ctx.ExecSQLWithResults(“select age from table1”);
while(reader1.Read()){
...
}
The second call to ExecSQLWithResults will result in the closing of the ‘reader1’ SqlDataReader and the ‘while’ loop will never execute.
If there are errors during the execution of the provided SQL Statement, this call will throw an exception. It will be up to the hook developer to catch these exceptions and it is very important that this is done or the survey will stop running resulting in your survey participant getting presented with an error page with very limited information.
HookContext Class | DatStat.Collector Namespace | ExecSQLCommand | SqlDataReader