我使用MySQL C Connector在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]我在while ((row = mysql_fetch_row(result)))
之后放置了MessageBox并且没有显示消息框,因此不会调用清除函数,并且第二个按钮推送程序崩溃。从数据库获取数据并显示是在单独的void函数中。
我的问题:
错误的查询语法会导致程序崩溃吗?
在清理之前,程序是否会脱离无效功能(奇怪)?
问候,大卫
答案 0 :(得分:1)
WHERE子句的最后一行有一个额外的AND
。改变这一行:
orders.worker_id = workers.id AND
对此:
orders.worker_id = workers.id