Solved

ADO MyODBC 3.51 MySQL problem with field sizes (ActualSize & DefinedSize)

Posted on 2006-06-15
2
332 Views
Last Modified: 2012-05-05
It's really very simple.
If you have a table with few varchar(255) fields, and you open it through ado, it doesn't give you the real field size, but instead is giving you (I think) the maximum lenght found for all values on that column. On my fields it is giving me all different values for ActualSize & DefinedSize for all varchar(255) fields, which is then making huge problems with my code!

I've read somewhere that this can be fixed with altering the connection string, but the author didn't say how :(

Here's some sample code:

    Dim cn As New ADODB.Connection
    cn.Open ConnectionString
    Dim rs As New ADODB.Recordset
    rs.Open "SELECT * FROM table", cn, adOpenStatic, adLockOptimistic
    MsgBox rs.Fields(0).ActualSize   ' shows 10
    MsgBox rs.Fields(0).DefinedSize ' shows 10

there's only one record there, and it is holding the value of '1234567890' in a single varchar(255) field.

How can I get the real field size!?!?!

Big thanks in advance
Lazar
0
Comment
Question by:kerzner
2 Comments
 
LVL 30

Accepted Solution

by:
todd_farmer earned 500 total points
ID: 16912202
ODBC isn't my cup of tea, but the documentation I've found indicates that perhaps setting the following flag might address your issues:

Don't optimize column widths    
0
 
LVL 1

Author Comment

by:kerzner
ID: 16923056
Well it really fixed it someway.
I put OPTION=3 at the end of my connection string and it kinda worked... except that it's not showing 255 still, but rather 765 (which is obviously 255x3) on *some* of the fields!!?? Anyway, it works for me that way, so thanks Todd
0

Featured Post

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction In this installment of my SQL tidbits, I will be looking at parsing Extensible Markup Language (XML) directly passed as string parameters to MySQL 5.1.5 or higher. These would be instances where LOAD_FILE (http://dev.mysql.com/doc/refm…
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now