如何在 C++ 中使用 setBlob() 设置二进制数据 连接器
我知道之前已经有人问过这个问题,并且我尝试实现该解决方案,但是当我调用 ps->executeUpdate() 时,我只是收到异常错误。 有人有明确的例子吗?
I know this has been asked before, and I tried to implement the solution, but I just get exception errors when I call ps->executeUpdate(). Has anyone got an explicit example?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这篇文章有点旧,但我遇到了同样的问题。 我采用了上面的方法,但它不太适合我的情况,我的情况是尝试获取一个向量并将其用于流。 我所做的就是获取 UUID 并将其转换为 16 字节二进制版本以在表中使用。 使用上面的方法,我发现只有一半的缓冲区被填充。
我最终使用了
stringstream
。还有一些其他事情需要记住。 在调用
execute
变体之一之前,不会访问该流。 因此,您需要保留流,直到运行execute
。希望这会对某人有所帮助并节省他们的时间。
This post is a bit old, but I ran across the same question. I employed the method above and it didn't quite work right for my case, which was trying to take a vector and use that for the stream. What I was doing was taking a UUID and converting it into a 16 byte binary version to use in the table. Using the method above, I found that only half my buffer was being populated.
I ended up using a
stringstream
.A few other things to keep in mind. The stream is not accessed until one of the
execute
variants is called. So you'll need to keep the stream around until you have runexecute
.Hopefully this will help someone and save them time.
抱歉,马修 - 我假设了这个问题的先前答案(由 elrohin 提供)。 也许我应该对此做出回应。 无论如何,这里是他建议的代码:
我正在使用 VS9 和最新的(测试版)连接器/cpp 调试库。 我还尝试过使用 char* 而不是字符串。
Sorry Matthew - I assumed the previous answer to this question (by elrohin). Maybe I should have replied to that. Anyway heres the code he suggested:
I'm using VS9 with the latest (beta) connector/cpp debug libs. I've also tried using char* instead of string.
这段代码对我来说效果很好:
希望它有帮助...... Jaroslav Pribyl
This code works fine for me:
hope it helps ... Jaroslav Pribyl