well, the problem is that I used it like this:
prep_stmt = con -> prepareStatement ("INSERT INTO City (CityNumber) VALUES 
(?)");
prep_stmt -> setInt (1, 23); //this statement didn’t act normally!!!

then when I execute the statement, the result does not appear to be correct, as 
CityNumber is not 23, I am sure that the field is integer.

I guess that something about number is not well delt in the PreparedStatement 
class.
If I use setString(1, "23"), the result is correct!!

thank you for your response!


-----邮件原件-----
发件人: Johan De Meersman [mailto:vegiv...@tuxera.be]
发送时间: 2013年2月19日 16:12
收件人: ZhangFangXue
抄送: mysql@lists.mysql.com
主题: Re: PreparedStatement problem

----- Original Message -----
> From: "ZhangFangXue" <zhangfang...@sogou-inc.com>
>
> Hi, when I use PreparedStatement in c++ connector, I find some
> unexcepted error,

Well, first of all, you don't actually say what the error is that you're 
seeing. This tends to be on the rather helpful side when trying to diagnose it.

> prep_stmt = con -> prepareStatement ("INSERT INTO City (CityName)
> VALUES (?)");
> prep_stmt -> setInt (1, 23); //this statement didn't act normally!!!

However, if you're inserting into a text field, it may well be that the parser 
will balk at you trying to bind an integer to that, no? If you want to insert a 
string, it's fairly common practice to provide an actual string to insert. 
Quite the novel idea, I know.

--
Unhappiness is discouraged and will be corrected with kitten pictures.

Reply via email to