CString不接受值吗?
![用户头像](/static/whole/images/alert/data-load/load-15.gif)
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 thatSqlStr3
is a valid string.
For example a common way to "break" aCString
object is to use itsGetBuffer
method, modify the string, and forget to callReleaseBuffer
...
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
系列文章
更多
同类精品
更多
-
保持在后台运行的 iPhone 应用程序完全可操作
it1352 07-25 -
iPhone,一张图像叠加到另一张图像上以创建要保存的新图像?(水印)
it1352 07-17 -
YouTube API 不能在 iOS (iPhone/iPad) 工作,但在桌面浏览器工作正常?
it1352 07-30 -
扫描 NFC 标签时是否可以启动应用程序?
it1352 08-02 -
使用 iPhone 进行移动设备管理
it1352 07-23 -
在android同时打开手电筒和前置摄像头
it1352 09-28 -
检查邮件是否发送成功
it1352 07-25 -
Android App 和三星 Galaxy S4 不兼容
it1352 07-20 -
复制文件夹/文件而不修改属性?
it1352 07-15 -
为什么字符'^'被Python Popen忽略 - 在Popen Windows转义'^'字符?
it1352 08-07