Results 1 to 5 of 5

Thread: [RESOLVED] OPTION on MySQL Connection String

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2006
    Posts
    57

    Resolved [RESOLVED] OPTION on MySQL Connection String

    hi...
    i found this code
    Code:
    Private Sub ConnServer()
      'connect to MySQL server using MySQL ODBC 3.51 Driver
      Set conn = New ADODB.Connection
      conn.ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver};" _
                            & "SERVER=localhost;" _
                            & " DATABASE=PERSONAL;" _
                            & "UID=root;PWD=root; OPTION=3"
    conn.Open
    End Sub
    on this threat for connect to mysql from VB6.

    in other web/blog, i found this code for connect to mysql from vb6
    Code:
     strConn = "DRIVER={MySQL ODBC 3.51 Driver};" _
                    & "SERVER=" & strServer & ";" _
                    & "DATABASE=manajemen_sms;" _
                    & "UID=" & UNAME & "; PWD=" & UPASS & ";" _
                    & "OPTION=" & 1 + 2 + 8 + 32 + 2048 + 16384
    - what is the purpose of use "OPTION=3"
    - where to get the other option parameter??

    thanks b4

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: OPTION on MySQL Connection String

    a quick googlling of "mysql connectionstring OPTION" turns up a thread where this exact question is asked... and points to this in the documentation for mySql...

    http://dev.mysql.com/doc/refman/5.0/...arameters.html

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Member
    Join Date
    Aug 2006
    Posts
    57

    Exclamation Re: OPTION on MySQL Connection String

    Quote Originally Posted by techgnome View Post
    a quick googlling of "mysql connectionstring OPTION" turns up a thread where this exact question is asked... and points to this in the documentation for mySql...

    http://dev.mysql.com/doc/refman/5.0/...arameters.html

    -tg
    thanks for your replay
    now i have a question, how to add other OPTION paramater on the connection string?? just use "+"??

    example: i need use parameter:
    • FLAG_LOG_QUERY
    • FLAG_NO_CACHE
    • FLAG_AUTO_RECONNECT
    • FLAG_AUTO_IS_NULL

  4. #4
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: OPTION on MySQL Connection String

    if you know their values, you add them... like in this example:
    "OPTION=" & 1 + 2 + 8 + 32 + 2048 + 16384

    OR... you add them up and figure out what the total value should be, and put it in there yourself like this:
    "OPTION=9999" (999 is just an example)

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  5. #5

    Thread Starter
    Member
    Join Date
    Aug 2006
    Posts
    57

    Talking Re: OPTION on MySQL Connection String

    many thanks

    I wrote a little enum (copying from the option page on MySQL documentation)
    little enum Code:
    1. Public Enum MyOption
    2.         'recommended option values for various configurations.
    3.         optVB = 3                      'Microsoft Access, Visual Basic
    4.         optLargeTables = 2049          'Large tables with too many rows
    5.         optSybasePB = 135168           'sysbase powerbuilder
    6.         optLT_nocache = 3145731         'Large tables with no-cache results
    7.  
    8.         'other Option Flags
    9.         optFieldLength = 1              'FLAG_FIELD_LENGTH       'Don't Optimize Column Width
    10.         optFoundRows = 2                'FLAG_FOUND_ROWS         'Return Matching Rows
    11.         optDebug = 4                    'FLAG_DEBUG              'Trace Driver Calls To myoptbc.log
    12.         optBigPacket = 8                'FLAG_BIG_PACKETS        'Allow Big Results
    13.         optNoPrompt = 16                'FLAG_NO_PROMPT          'Don't Prompt Upon Connect
    14.         optDynamicCursor = 32           'FLAG_DYNAMIC_CURSOR     'Enable Dynamic Cursor
    15.         optNoSchema = 64                'FLAG_NO_SCHEMA          'Ignore # in Table Name
    16.         optNoDefaultCursor = 128        'FLAG_NO_DEFAULT_CURSOR  'User Manager Cursors
    17.         optNoLocale = 256               'FLAG_NO_LOCALE          'Don't Use Set Locale
    18.         optPadSpace = 512               'FLAG_PAD_SPACE          'Pad Char To Full Length
    19.         optFullColumnNames = 1024       'FLAG_FULL_COLUMN_NAMES  'Return Table Names for SQLDescribeCol
    20.         optCompressedProto = 2048       'FLAG_COMPRESSED_PROTO   'Use Compressed Protocol
    21.         optIgnoreSpace = 4096           'FLAG_IGNORE_SPACE       'Ignore Space After Function Names
    22.         optNamedPipe = 8192             'FLAG_NAMED_PIPE         'Force Use of Named Pipes
    23.         optNoBigInt = 16384             'FLAG_NO_BIGINT          'Change BIGINT Columns to Int
    24.         optNoCatalog = 32768            'FLAG_NO_CATALOG         'No Catalog
    25.         optUseMyCnf = 65536             'FLAG_USE_MYCNF          'Read Options From my.cnf
    26.         optSafe = 131072                'FLAG_SAFE               'Safe
    27.         optNoTransactions = 262144      'FLAG_NO_TRANSACTIONS    'Disable transactions
    28.         optLogQuery = 524288            'FLAG_LOG_QUERY          'Save queries to myodbc.sql
    29.         optNoCache = 1048576            'FLAG_NO_CACHE           'Don't Cache Result (forward only cursors)
    30.         optForwardCursor = 2097152      'FLAG_FORWARD_CURSOR     'Force Use Of Forward Only Cursors
    31.         optAutoReconnect = 4194304      'FLAG_AUTO_RECONNECT     'Enable auto-reconnect.
    32.         optAutoIsNull = 8388608         'FLAG_AUTO_IS_NULL       'Flag Auto Is Null
    33.         optZeroDateToMin = 16777216     'FLAG_ZERO_DATE_TO_MIN   'Flag Zero Date to Min
    34.         optMinDateToZero = 33554432     'FLAG_MIN_DATE_TO_ZERO   'Flag Min Date to Zero
    35.         optMultiStatements = 67108864   'FLAG_MULTI_STATEMENTS   'Allow multiple statements
    36.         optColumnSizeS32 = 134217728    'FLAG_COLUMN_SIZE_S32    'Limit column size to 32-bit value
    37. End Enum

    the Sample Code:
    1. Public Function KonekToServer(strServer As String, UNAME As String, UPASS) As Boolean
    2.     On Error GoTo errHandle
    3.     Dim MyOdbcOption
    4.     MyOdbcOption = optFoundRows + optVB + optBigPacket + optDynamicCursor + _
    5.                 optCompressedProto + optNoBigInt + optAutoReconnect
    6.    
    7.     strConn = "DRIVER={MySQL ODBC 3.51 Driver};" _
    8.                 & "SERVER=" & strServer & ";" _
    9.                 & "DATABASE=ManajemenSekolah;" _
    10.                 & "UID=" & UNAME & "; PWD=" & UPASS & ";" _
    11.                 & "OPTION=" & MyOdbcOption
    12.                
    13.     Set KonekDB = New ADODB.Connection
    14.     KonekDB.CursorLocation = adUseClient
    15.     KonekDB.ConnectionString = strConn
    16.     KonekDB.Open
    17.    
    18.     KonekToServer = True
    19.    
    20.     Exit Function
    21.    
    22. errHandle:
    23.     MsgBox Err.Description & vbCrLf & vbCrLf & strConn
    24.     KonekToServer = False
    25. End Function


    problem solved......

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width