• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

CString不接受值吗?

用户头像
it1352
帮助1

问题说明

我正在使用以下代码将值插入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  ="'';";

正确答案

#1
检查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.

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /reply/detail/tanhefjfca
系列文章
更多 icon
同类精品
更多 icon
继续加载