Knowledgebase

Search:     Advanced search

QA Wizard Pro OpenRecordsetQuery Statements Using SQL Queries with Single Quotes Do Not Work

Article ID: 799  |  Last updated: 07 Jun, 2017

Problem

Using the QA Wizard Pro OpenRecordsetQuery statement with a SQL query argument that contains single quotes does not work and a syntax error is returned.

Cause

SQL queries require single quotation marks with a Unicode value of 0096 (decimal). The single quote characters used in the QA Wizard Pro script editor are Unicode value 0039 (decimal).

Solution

Use the Chr function to convert single quotes in the SQL query to the correct Unicode character. The following example shows the correct syntax:

query = "SELECT * FROM [Sheet1$] WHERE " + Chr(0096) + "First Name" + Chr(0096) + "=""John"""

dataset = OpenRecordSetQuery("Wysicorp EXCEL Data", query)

Article ID: 799  |   Last updated: 07 Jun, 2017
Tags
OpenRecordsetQuery quotation mark single quote syntax error SQL query

Prev   Next
Web Controls Not Displayed in QA Wizard Pro Preview Screenshots     Testing .NET Windows Forms Applications with QA Wizard Pro