Solved

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

Posted on 2006-06-15
2
338 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Foreword In the years since this article was written, numerous hacking attacks have targeted password-protected web sites.  The storage of client passwords has become a subject of much discussion, some of it useful and some of it misguided.  Of cou…
I use MySQL for many of my development projects in a Windows environment. To manage my databases (and perform queries) for years I used a tool called MySQL administrator.  This tool has since been replaced by MySQL Workbench. So I decided to m…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

789 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