0

So I'm using a connection string from my app.config file to connect to my database. I also tried to make it more secure, so that my SqlCOnnectionStringBuilder retrieves its info from the app.config file. To give you a better idea of what I mean here's some code:

app.config:

<connectionStrings>
  <clear/>
  <add name="connection"
       connectionString="Data Source=SERVERIP; Initial Catalog=DB; 
                        Port=3306; User ID=USERNAME; Password=PASSWORD;"
       providerName="System.Data.SqlClient" />
</connectionStrings>

Method for the connection builder:

    private void BuildConnectionString()
    {
        ConnectionStringSettings settings = 
            ConfigurationManager.ConnectionStrings["connection"];

        if (null != settings)
        {
            MySqlConnectionStringBuilder builder =
                new MySqlConnectionStringBuilder(settings.ConnectionString);

            conString = builder.ConnectionString;
        }
    }

Somehow the user id gets replaced with the name of my computer, which is very wierd since the IP, port and the initial catalog aren't being replaced.

Oh and I followed this handy article here on MSDN.

Can someone please tell me what I'm doing wrong here?

EDIT: Here is the full error I'm getting:

An unhandled exception of type 'MySql.Data.MySqlClient.MySqlException' occurred in MySql.Data.dll

Additional information: Host 'nameofpc' is not allowed to connect to this MariaDB server

Community
  • 1
  • 1
Berend Hulshof
  • 1,039
  • 1
  • 16
  • 36

1 Answers1

-2

It seems to me that the problem is that the MariaDB server is only accepting incoming connections from a certain set of hosts. Most likely the server is defaulted to accept only localhost connections. I think that this link might be helpful: https://mariadb.com/kb/en/mariadb/configuring-mariadb-for-remote-client-access/.

Zalomon
  • 553
  • 4
  • 14
  • How is this answer direspectful or off topic to deserve downvoting when the error he's getting points exactly to the cause I mentioned? – Zalomon May 12 '16 at 12:54
  • 1
    I tried editting the user settings, which didn't work. And the server accepts every connection so it isn't that. this is not "exactly" pointing to the cause of the error. – Berend Hulshof May 12 '16 at 12:57
  • Are you able to connect with that user from a different machine? – Zalomon May 12 '16 at 13:07
  • What's on the host column for the user that you trying to connect with? – Zalomon May 12 '16 at 13:08
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/111764/discussion-between-zalomon-and-b-hulshof). – Zalomon May 12 '16 at 13:20
  • 1
    See [this answer](http://stackoverflow.com/a/1559992/43846) regarding the host column wildcard – stuartd May 12 '16 at 13:46