覆盖字符串的引号C++消失
The quotes that cover the string disappear C++
我尝试用引号覆盖字符串,以便将其放入SQL记录中
int pictureId = picture.getId();
std::string pictureName = "'" + picture.getName() + "'";
std::string picturePath = "'" + picture.getPath() + "'";
std::string pictureCreationTime = "'" + picture.getCreationDate() + "'";
std::string TRY = "Insert Into Pictures(Id, Name, Location, Creation_Date,
Album_id) Values(" + std::to_string(picture.getId()) + ',' +
picture.getName() + "," + picture.getPath() + ',' +
picture.getCreationDate() + ',' + '1' + ");";
res = sqlite3_exec(db, TRY.c_str(), nullptr, nullptr, &errMessage);
行后
std::string TRY = "Insert Into Pictures(Id, Name, Location, Creation_Date,
Album_id) Values(" + std::to_string(picture.getId()) + ',' +
picture.getName() + "," + picture.getPath() + ',' +
picture.getCreationDate() + ',' + '1' + ");";
引号消失我能做什么才能使报价不会消失
单引号消失在您说导致问题的行上,您使用 picture.getName(( 而不是使用您使用单引号创建的 pictureName 字符串。
int pictureId = picture.getId();
std::string pictureName = "'" + picture.getName() + "'";
std::string picturePath = "'" + picture.getPath() + "'";
std::string pictureCreationTime = "'" + picture.getCreationDate() + "'";
std::string TRY = "Insert Into Pictures(Id, Name, Location, Creation_Date,
Album_id) Values(" + std::to_string(pictureId ) + ',' +
pictureName + "," + picturePath + ',' +
pictureCreationTime + ',' + '1' + ");";
相关文章:
- 将地址分配给本地指针后,公共对象的变量将消失
- 应用投影矩阵后对象消失
- 添加自定义析构函数时,Move 构造函数在派生类中消失
- 在 Linux 中使用 ioctl() 获取隐藏功能报告时,零字节消失
- 应用地址清理器后,免费无效指针消失
- 返回的指针属性中类实例上的矢量属性消失
- 自动消失的自定义消息框
- 该程序没有产生输出,而是卡在一个循环中,几秒钟后消失并打印被杀死?
- C++ 在地图上循环 - 消失的对象
- 我收到一个断言错误,但是当我编写 cout 语句时,它会消失
- 使用Valgrind时内存泄漏消失
- 为什么在我释放左键单击后,我的绘图会消失
- 智能感知 PCH 警告不会消失
- C++ :: 设置值函数在函数内设置,但后跟 Get 函数,设置值消失了
- c++ – 消失的变量
- FreeGLUT窗口在启动时消失
- mysql c ++连接器异常:用户"root"@'localhost'的访问被拒绝(使用密码:NO)&&MySQL服务器已消失
- 我们如何在范围消失时通过引用返回变量
- MSVC C6029 警告:缓冲区可能溢出,使用未经检查的值.检查缓冲区大小时,警告不会消失
- 添加新纹理OpenGL时,模型消失了