Solved

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

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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

I have been using r1soft Continuous Data Protection (http://www.r1soft.com/linux-cdp/) for many years now with the mySQL Addon and wanted to share a trick I have used several times. For those of us that don't have the luxury of using all transact…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

713 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