.:: Bots United ::.

.:: Bots United ::. (http://forums.bots-united.com/index.php)
-   General Bot Coding (http://forums.bots-united.com/forumdisplay.php?f=24)
-   -   mySQL + HPB_bot (http://forums.bots-united.com/showthread.php?t=5994)

RedLink 19-12-2006 22:23

mySQL + HPB_bot
 
Well I've been trying to integrate MySQL++ into HPB_bot, thou I've got a major problem. I've succeeded to connect to my SQL database thou any attempt to fetch or insert information results in a crash.

Sample code
Code:

mysqlpp::Connection con("test","127.0.0.1","test","test");
mysqlpp::Query query = con.query();
...
sprintf( buff, "INSERT INTO chat (id,message,date) VALUES('','%s','NOW()')\0",szMsg_buff);
...
mysqlpp::Result res = query.store(buff)



I'm guessing I'll haft to make a separate thread, is there a way to get past this obstacle as smooth as possible?

Cheeseh 20-12-2006 00:15

Re: mySQL + HPB_bot
 
you should ALWAYS try and catch for SQL Exceptions when using SQL. As the sql command will likely contain syntax errors and the only way to know there is a syntax error is to raise an exception. If the exception is not handled (handled = using try and catch), the program will crash.

see: http://tangentsoft.net/mysql++/doc/u.../tutorial.html


All times are GMT +2. The time now is 22:23.

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.