Home arrow MySQL arrow Page 2 - MySQL and BLOBs
MYSQL

MySQL and BLOBs


One of MySQL's strengths is its use of Binary Large Object (BLOB) columns. These columns store unprocessed binary data, typically files, that can be retrieved and manipulated like the other common datatypes. The difficulty comes in accessing the BLOB column in VB. Prior to ADO 2.5, the only way to move data in and out of a MySQL BLOB column using Visual Basic was to use the appendchunk and getchunk methods. With ADO 2.5, the stream object has been added, greatly simplifying the process of working with MySQL BLOBs. In this article, I will focus entirely on using the stream object.

Author Info:
By: Mike Hillyer
Rating: 4 stars4 stars4 stars4 stars4 stars / 99
May 18, 2004
TABLE OF CONTENTS:
  1. · MySQL and BLOBs
  2. · Connection String
  3. · Connection Object
  4. · Sending Data Into the BLOB Column
  5. · Retreiving Data
  6. · Update File - We're Done!

print this article
SEARCH DEVARTICLES

MySQL and BLOBs - Connection String
(Page 2 of 6 )

Ok, now that we have configured MySQL and VB, we can move on to writing the client app. First, let's look at the connection string. The connection string is what determines how VB will connect to the server, it specifies the ODBC driver (MyODBC), the address of the server, the username and password used to connect, and the database name. In addition, the specific options used to connect are also specified. Following is the connection string I use for my application. 

 "DRIVER={MySQL ODBC 3.51 Driver};" _
            & "SERVER=127.0.0.1;" _
            & "DATABASE=test;" _
            & "UID=testuser;" _
            & "PWD=12345;" _
            & "OPTION=" & 1 + 2 + 8 + 32 + 2048 + 16384


I populate the UID and PWD sections using values from my login prompt, and then store the completed connection string in a global variable stored in a module. The remainder is static and is part of a pre-built string. A quick note on the option values; the options specified include the following:

1 - Client Can't handle the real column width being returned.

2 - Have MySQL return found rows value.

8 - Allow Big Values: We want the server to send out the BLOB values to our VB client (large packets), so this option must be set.

32 - Toggle Dynamic cursor support.

2048 - Enable The MySQL Compressed Protocol.

16384 - Convert LongLong to Int: This just helps makes sure that large numeric results get properly interpreted.

The 1, 2, and 32 options are taken from the ADO code sample on the MySQL website, found here.


blog comments powered by Disqus
MYSQL ARTICLES

- MySQL and BLOBs
- Two Lessons in ASP and MySQL
- Lord Of The Strings Part 2
- Lord Of The Strings Part 1
- Importing Data into MySQL with Navicat
- Building a Sustainable Web Site
- Creating An Online Photo Album with PHP and ...
- Creating An Online Photo Album with PHP and ...
- PhpED 3.2 More Features Than You Can Poke ...
- Creating An Online Photo Album with PHP and ...
- Creating An Online Photo Album with PHP and ...
- Security and Sessions in PHP
- Setup Your Personal Reminder System Using PHP
- Create a IP-Country Database Using PERL and ...
- Developing a Dynamic Document Search in PHP ...

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials