Solved

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

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

A lot of articles have been written on splitting mysqldump and grabbing the required tables. A long while back, when Shlomi (http://code.openark.org/blog/mysql/on-restoring-a-single-table-from-mysqldump) had suggested a “sed” way, I actually shell …
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

760 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

18 Experts available now in Live!

Get 1:1 Help Now