0

我正在使用 MySQL C 连接器在 Visual C++ 中编写。

当我 StringCchPrintf 这个查询并执行并获得结果时,就可以了。

SELECT orders.id, 
orders.get_date, 
orders.work_date, 
cars.car_num, 
cars.car_mark, 
customers.surname, 
customers.name, 
customers.telephone, 
workers.login, 
orders.paid, 
orders.paid_dead_line 
FROM `orders`, `cars`, `customers`, `workers` 
WHERE cars.customer_id = customers.id AND 
orders.car_id = cars.id AND 
orders.customer_id = customers.id AND 
orders.worker_id = workers.id AND 
DATE(get_date) LIKE DATE('%d-%d-%d') 
ORDER BY get_date ASC;

当我 StringCchPrintf 下面的查询 - 程序没有调用免费函数 [1] 并且当我再次按下按钮时,我的应用程序崩溃了。

SELECT orders.id, 
orders.get_date, 
orders.work_date, 
cars.car_num, 
cars.car_mark, 
customers.surname, 
customers.name, 
customers.telephone, 
workers.login, 
orders.paid, 
orders.paid_dead_line 
FROM `orders`, `cars`, `customers`, `workers`  
WHERE orders.paid IN ('0', '2', '3') AND //1 == paid
cars.customer_id = customers.id AND 
orders.car_id = cars.id AND 
orders.customer_id = customers.id AND 
orders.worker_id = workers.id
ORDER BY get_date ASC;

[1] 我把 MessageBox 放在之后while ((row = mysql_fetch_row(result)))并且没有显示消息框,所以没有调用清理函数并且在第二个按钮推送程序崩溃。从数据库中获取数据并显示在单独的 void 函数中。

我的问题:

错误的查询语法会导致程序崩溃?

也许程序在清理之前会退出 void 功能(奇怪)?

问候,大卫

4

1 回答 1

1

AND您的 WHERE 子句的最后一行有一个额外的内容。更改此行:

orders.worker_id = workers.id AND 

对此:

orders.worker_id = workers.id
于 2013-06-10T15:34:08.313 回答