Quantcast
Channel: Xamarin.Mac — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 1429

I have tried everything to get my Mac app to connect to MySQL.

$
0
0

I have MySql.Data.dll version 6.10.5.0 installed and selected in the .Net Assembly tab:

Here is my code:

using System;
using AppKit;
using Foundation;
using MySql;
using MySql.Data;
using MySql.Data.MySqlClient;

namespace Mysqlteest
{
    public partial class ViewController : NSViewController
    {
        public ViewController(IntPtr handle) : base(handle)
        {
        }

        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            string connectionString =
                   @"Server=127.0.0.1;" +
                @"Port=3306;" +
                   @"User ID=root;" +
                   @"Password=************;" +
                   @"Database=Career Progress;" +
                @"Pooling=false;";

            //      Now we make the connection.

            MySqlConnection mySqlConnection = new MySqlConnection();
            mySqlConnection.ConnectionString = connectionString;

            //      The Open method works!
            //      And the Open method fails correctly when wrong credentials are used.
            mySqlConnection.Open();
            mySqlConnection.Close();

            // Do any additional setup after loading the view.
        }

It will throw an exception on the mySqlConnection.Open(); I am just trying a test app to see if I can get it to work.

No matter what I try I can not get it to work.

Help Please.


Viewing all articles
Browse latest Browse all 1429

Trending Articles