470,572 Members | 2,087 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,572 developers. It's quick & easy.

Upload file contents to database using C API

What I am trying to do is to take the contents of a very large text
file and place it into a LONGTEXT field in a database. I am looking
for a solution using the C API to help me handle this. The code I use
right now is very ineffecient. I basically use a VERY large character
array that is like 600,000 characters long and store an UPDATE query to
the database in this. I place the contents of the file being uploaded
into this query where I SET the LONGTEXT field to the file contents. I
know there has to be a much better way of handling this, so if you have
any ideas, please let me know. Thanks alot.

Brad

Mar 15 '06 #1
1 1575
<bb****@gmail.com> wrote in message
news:11*********************@e56g2000cwe.googlegro ups.com...
What I am trying to do is to take the contents of a very large text
file and place it into a LONGTEXT field in a database. I am looking
for a solution using the C API to help me handle this.


You could use mysql_stmt_prepare() to prepare a parameterized SQL statement,
using ? in place of the value for the LONGTEXT field. Then use
mysql_stmt_send_long_data() to push the data to the server segment by
segment.

See code example here:
http://dev.mysql.com/doc/refman/5.0/...long-data.html

Regards,
Bill K.
Mar 15 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by wakun | last post: by
4 posts views Thread by Jim Michaels | last post: by
9 posts views Thread by Wayne Smith | last post: by
6 posts views Thread by Vic Spainhower | last post: by
9 posts views Thread by Steve Poe | last post: by
1 post views Thread by livre | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.