警告:缺少终止字符“>

问题描述 投票:1回答:2

我正在制作一个连接到SQL数据库的C ++程序。该查询确实很长,可能不是解决该问题的最佳方法,但这并不重要。此错误是指此代码中的第一个",紧接在SELECT之前。不知道问题是什么考虑到结尾"在函数的末尾。我以为我需要在某些地方使用一些转义字符,但我似乎并没有在任何地方使用它们。

res = stmt->executeQuery("SELECT customers.customerNumber, customers.customerName, customers.phone, customers.creditLimit, orders.orderNumber, orders.orderDate, orders.status, products.productName, orderdetails.quantityOrdered, orde
rdetails.priceEach, employees.firstName, employees.lastName, employees.email
AS returnedInfo
FROM customers
JOIN orders ON customers.customerNumber=orders.customerNumber
JOIN orderdetails ON orders.orderNumber = orderdetails.orderNumber
JOIN products ON orderdetails.productCode = products.productCode
JOIN employees ON customers.salesRepEmployeeNumber = employees.employeeNumber
WHERE customers.customerNumber = \'103\';");

我正在制作一个连接到SQL数据库的C ++程序。该查询确实很长,可能不是解决该问题的最佳方法,但这并不重要。此错误是指第一个“ ...

c++ c-strings string-literals
2个回答
3
投票

文字字符串需要在行结束之前结束。您可以通过使用预处理器的行继续方法来解决此问题,如


3
投票

您需要raw string literal(在C ++ 11中引入)。问题是,默认情况下,您不能在字符串中放置实际的换行符(而不是\n),但是可以使用原始字符串文字。

© www.soinside.com 2019 - 2024. All rights reserved.