cannot connect mysql using odbc connector RRS feed

  • Question

  • User323004166 posted

    hi all i have install mysql odbc driver 5.2  in my windows machine. i have set up an system DSN to connect to mysql  database and connection success. 

    then i have wrote a code to get dataset from mysql using c# using odbc and connection string 

    DataSet result = null;
    string constr = "Driver={MySQL ODBC 5.2 UNICODE Driver};Server=ipaddress;Port=3306;Database=mydatabase;User=username;Password=paassword;Option=3;";
    OdbcConnection odbccon = new OdbcConnection(constr);
    OdbcCommand odbccomd = new OdbcCommand();
    odbccomd.Connection = odbccon;
    //odbccomd.CommandText = sql;
    OdbcDataAdapter da = new OdbcDataAdapter(sql, odbccon);
    DataSet ds = new DataSet();
    da.Fill(ds, "temp");
    result = ds;
    da = null;
    ds = null;
    return result;

    then i call this function with sql (sql give result when i run it on mysql - sql syntax correct)

    I get below error


       at System.Data.Odbc.OdbcConnection.HandleError(OdbcHandle hrHandle, RetCode retcode)

       at System.Data.Odbc.OdbcConnectionHandle..ctor(OdbcConnection connection, OdbcConnectionString constr, OdbcEnvironmentHandle environmentHandle)

       at System.Data.Odbc.OdbcConnectionOpen..ctor(OdbcConnection outerConnection, OdbcConnectionString connectionOptions)

       at System.Data.Odbc.OdbcConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject)

       at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup)

       at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)

       at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)

       at System.Data.Odbc.OdbcConnection.Open()

    Wednesday, February 12, 2014 12:16 PM

All replies

  • User197322208 posted

    what is the error message?

    Friday, February 14, 2014 6:36 AM