CString不接受值吗? [英] CString is not accepting values?

查看:66
本文介绍了CString不接受值吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下代码将值插入MYSQL数据库.在此CString中,SqlStr4接受并采用sqlstr3假设之前的值,此后不采用其他值.这是什么问题呢?帮帮我.

I am using the following code to insert the values into the MYSQL database. In this CString SqlStr4 is accepting and taking values up to sqlstr3 assumption, after that it is not taking the other values. What is the problem in this?? help me.

CString SqlStr4;
SqlStr4 = "INSERT INTO log SET grab_date= ''";
SqlStr4 +=strDateTime;
SqlStr4 += "'',ip_address=''";
SqlStr4 +=SqlStr3;
SqlStr4 += "'',image=''";
SqlStr4 += StrByte;
SqlStr4 +="'';";

推荐答案

检查SqlStr3是有效的字符串.
例如,破坏" CString对象的一种常用方法是使用其GetBuffer方法,修改字符串,而忘记调用ReleaseBuffer ...

我不明白这可能是错的.尝试注释几行,以确切地知道哪一条引发了该问题.例如:
Check that SqlStr3 is a valid string.
For example a common way to "break" a CString object is to use its GetBuffer method, modify the string, and forget to call ReleaseBuffer...

I don''t understand what might be wrong. Try to comment a few lines to know exactly which one raises the problem. For example:
CString SqlStr4;
SqlStr4 = "INSERT INTO log SET grab_date= '";
SqlStr4 +=strDateTime;
SqlStr4 += "',ip_address='";
//SqlStr4 +=SqlStr3;
SqlStr4 += "',image='";
SqlStr4 += StrByte;
SqlStr4 +="';";



一旦找到导致问题的行(可能是几行),请对该字符串执行相同的操作.例如,如果您发现只有SqlStr3会导致此问题,请仔细查看SqlStr3的构建方式.尝试以其他方式构建它...



Once you found which lines (it might be several ones) causes the problem, do the same thing with that string. For example, if you found out that only SqlStr3 causes the problem, then look carefully how SqlStr3 is built. Try to build it a different way...


不接受"是什么意思?您是说在构建SqlStr4时收到运行时错误,还是数据库抱怨传递的字符串?如果是后者,ip_address实际上是字符串类型吗?也许您应该跳过此字段上的引号?
What do you mean by ''does not accept''? Do you mean you get a runtime error while building SqlStr4, or does your database complain about the string you pass? If the latter, is ip_address actually a string type? maybe you should skip the quotes on this field?


这只是一个预感,但是SqlStr3是否有可能是unicode字符串?我问的原因是,看来您的其他字符串不是unicode,也许是造成您的问题的原因.
只是一个想法.
This is just a hunch, but is there any chance that SqlStr3 is a unicode string? The reason I ask is that it appears that your other strings are not unicode and perhaps that is causing your problem.

Just a thought.


这篇关于CString不接受值吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆