Forum Moderators: open

Message Too Old, No Replies

Connecting to Remote Host MYSQL Server

         

latoc

5:11 pm on Apr 2, 2010 (gmt 0)

10+ Year Member



I am having problems connecting to Mysql database at my host. The database has been configured (table and 5 fields, manually imputed with test data) my host have confirmed the IP and port to the database server. Research has lead me to countless connection string all failed to connect. The latest one listed below uses the web.config file:

<connectionStrings>
<add name=" ConnStringName" connectionString="MySQLExampleServer; port=3362;uid=Data;pwd=1234;database=mydatabase" providerName="System.Data.SqlClient"/>
</connectionStrings>


Connection String in Page.aspx

Dim myConnection As SqlConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("ConnStringName").ConnectionString)


I understand that SqlClient is an error requiring MYSQL provider. I have downloaded MySQL Connector Net 6.2.2
I am not sure this is the correct method. Advice on how to incorporate MYSQL connector in the above would be appreciated.

latoc

[edited by: Ocean10000 at 8:52 pm (utc) on Apr 2, 2010]
[edit reason] Examplified Server Name [/edit]

Ocean10000

9:10 pm on Apr 2, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



First things first, you were using the wrong data access provider. The one you want to use is "MySql.Data.MySqlClient", which you downloaded already. I have updated the connection string accordingly.

<connectionStrings>
<add name="ConnStringName" connectionString="MySQLExampleServer; port=3362;uid=Data;pwd=1234;database=mydatabase" providerName="MySql.Data.MySqlClient"/>
</connectionStrings>


Dim myConnection As MySql.Data.MySqlClient.MySqlConnection = New MySql.Data.MySqlClient.MySqlConnection(ConfigurationManager.ConnectionStrings("ConnStringName").
ConnectionString)

[edited by: Ocean10000 at 10:58 pm (utc) on Apr 2, 2010]

latoc

9:59 pm on Apr 2, 2010 (gmt 0)

10+ Year Member



Thank you for the correction and revised code.

Unfortunately there is still an error: BC30002: Type 'MySql.Data.MySqlClient.MySqlConnection' is not defined.

My imports are:
<%@ import Namespace="System.Data.Odbc" %>
<%@ Import Namespace="System.Data.SqlClient.SqlConnection" %>

Sorry for carelessly leaving the IP in the post, I feel like I’m ‘pushing water up hill’ with this problem. It must be affecting my mind!

Any assistants will be appreciated.

latoc

Ocean10000

10:58 pm on Apr 2, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Did you install MySQL Connector Net 6.2.2 on the server, where you are serving the pages from? I think the last error is that it can not find the class's or the namespace which to access MySQL.

This will just define that you are importing the MySqlClient namespace. (still requires the connector to be installed)
<%@ Import Namespace="MySql.Data.MySqlClient" %>

latoc

1:34 pm on Apr 3, 2010 (gmt 0)

10+ Year Member



The MySQL Connector Net 6.2.2 together with MySQL Server 5.1 is in MySQL folder in program files.

I have added a reference in the connectionString of the web.config file.

<add name="MYSQL_ODBC" connectionString="DRIVER={MYSQL ODBC 6.2.2 Driver}"></add>
And added
<%@ Import Namespace="MySql.Data.MySqlClient" %> to the list of imports.

Clearly my interpretation of your advice is wrong as I still get the same error

I have raised a post with my host providers to enquire if they support the driver. Awaiting reply.

As is obvious this is my first attempt with MySQL. Any help would be most welcome.