Solved

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

Posted on 2006-06-15
2
341 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction In this article, I will by showing a nice little trick for MySQL similar to that of my previous EE Article for SQLite (http://www.sqlite.org/), A SQLite Tidbit: Quick Numbers Table Generation (http://www.experts-exchange.com/A_3570.htm…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

734 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