locked
ODBC connector for mysql RRS feed

  • Question

  • User363754837 posted

    anybody had an idea about

    ODBC connector

    i am trying to test my connection to mysql but after i entered all my information i am getting the following messagebox error:

    Connection Failed:[HY000][MySQL][ODBC 5.1 Driver] Unknown system variable 'character_set_results'

    I don't know what is the problem at this point looking for answers???

    Friday, May 8, 2009 3:00 PM

All replies

  • User1759999623 posted

    What version of MySQL are you using?  If it's older than 5.1, then you might want to consider using an older version of the ODBC driver.

    Friday, May 8, 2009 3:31 PM
  • User363754837 posted

    I am using version 4.0 and and tried both connectors versions 5.1 and the 3.51 but i am still getting the same error if i try the version 5 it tells me that it cannot find the data source and if i use the verison 3.5 i get the error i mentioned previousely.

    Thanks

    Monday, May 11, 2009 10:37 AM
  • User1759999623 posted

    Have you ever been able to connect to a MySQL database through the ODBC connector and .NET?

    Tuesday, May 12, 2009 4:43 PM
  • User363754837 posted

    No sir the only time i can do it is from my machine but when i upload the files to my site i could not i am still looking for answers if you have any please forward them to me i got my public server which i can connect to locally but outside my machine is negative...

    Thanks

    Thursday, May 28, 2009 3:01 PM
  • User363754837 posted

    and here is my connection string

    strconnection = New OdbcConnection("DRIVER={mySQL ODBC 3.51 Driver};myserveraddress;Port=3306;Stmt=;DATABASE=databasename;UID=username;PASSWORD=password;OPTION=3;")

    Thursday, May 28, 2009 3:03 PM
  • User1759999623 posted

    It sounds like that you do not have full access to this server, thus it blocks the connection to your database from the outside.  First, you need to look at your security settings to make sure that your ASPNET user has access to your MySQL database.  Secondly, you need to make sure that the ports are opened to the outside.

    Friday, May 29, 2009 2:15 PM
  • User318696944 posted

    This is correct. While I thought that I added my IP address/Class C to the Remote MySQL Access Host list (which is located in cPanel, if that's what your host is using), I forgot that I was connecting from a different location. Once I added my IP address, everything worked perfectly.

    Here is the connection code I used to get my desktop application to work. Specifically, I am using Microsoft Visual Basic 2010 Express with MySQL ODBC Driver 5.1 in a Microsoft Windows XP 32-bit environment. The server I connected to is a Linux shared server running cPanel 11.30.3 (build 5) and MySQL version 5.1.59

    The MySQL ODBC Driver I used is available here.
    Specifically, for 32-bit, mysql-connector-odbc-5.1.9-win32.msi is the direct download

    Below is the code I used to connect. I hope it helps others out there.

    Sub OpenMySQLConnection()
    Dim mConnection As Odbc.OdbcConnection

    ' First, build a connection if one doesn't already exist
    If mConnection Is Nothing Then mConnection = New Odbc.OdbcConnection

    ' Is the connection is already open? If so, close it.
    If mConnection.State = ConnectionState.Open Then mConnection.Close()

    ' Initialize a few local variables to store the MySQL username, password, location, driver name and database name.
    Dim username As String = "mySQLusername"
    Dim password As String = "mySQLpassword"
    Dim server As String = "somewhere.doc"
    Dim driver As String = "{MySQL ODBC 5.1 Driver}"
    Dim database As String = "mySQLdatabaseName"

    ' Build the connection string object
    myConnectionString = "Driver=" & driver & "; Server=" & server & "; User=" & username & "; Password=" & password & ";Database=" & database & ";"

    ' Now attempt to open the connection to the database
    mConnection.ConnectionString = myConnectionString
    Try
    mConnection.Open()
    Catch ex As Exception
    'Unable to connect. To read the error, add this to a message box somewhere: ex.ToString
    'For example: MsgBox("Unable to connect due to the following error: " & ex.ToString)
    'Write code below to execute more steps since you're unable to connect.
    End Try

    ' See if the connection state opened correctly (successfully)
    If mConnection.State <> ConnectionState.Open Then
    'Execute code if an error occurred while attempting to open
    ElseIf mConnection.State = ConnectionState.Open Then
    'All is well! Insert additional code to manipulate database here
    End If
    End Sub

    Sunday, November 13, 2011 11:40 AM
  • User814302705 posted

    You have to put the connection string in the web.config file.

     

    Micheel3000

    Wednesday, July 18, 2012 6:36 AM