how do you connect to a Mysql Server on Webhost

red

Member
Joined
Oct 16, 2013
Messages
15
Programming Experience
1-3
Good evening,

I have cpanelx, hence I have this problem, am trying to make a program that could run on LAN, but the application should connect to a mysql database on a Cpanel X server (webhosting) how do I go about this?

Possible snippets could be helpful.
 

jmcilhinney

C# Forum Moderator
Staff member
Joined
Apr 23, 2011
Messages
3,134
Location
Sydney, Australia
Programming Experience
10+
I don't really know what Cpanel X is but it really doesn't matter I don't think. If you want to connect to a MySQL database then start by downloading Connector/Net from the MySQL web site and installing it. You would then reference MySql.Data.dll in your project. I believe that there is also a NuGet package available. Once that's done, you can use the MySqlClient provider to connect to MySQL in basically the same way you would use the SqlClient provider to connect to SQL Server. The code is the same whether you're connecting to a local or remote database. All that changes is the connection string, for which you can find information at ConnectionStrings.com.
 

red

Member
Joined
Oct 16, 2013
Messages
15
Programming Experience
1-3
Looking at it now, I presume it allows for data binding also? Pls let me know.
 

red

Member
Joined
Oct 16, 2013
Messages
15
Programming Experience
1-3
Ok suppose the remote ip of my mysql database is 62.1.138.51, how do I use this connection string to connect to it

I have something like this
C#:
Driver={MySQL ODBC 5.2 ANSI Driver};Server=62.1.138.51;Database=myDataBase;
User=myUsername;Password=myPassword;Option=3;
 

jmcilhinney

C# Forum Moderator
Staff member
Joined
Apr 23, 2011
Messages
3,134
Location
Sydney, Australia
Programming Experience
10+
Looking at it now, I presume it allows for data binding also? Pls let me know.
Connecting to a database has nothing to do with data-binding. Data-binding involves creating a relationship between a local data source and the UI. How that local data source gets populated is completely irrelevant to data-binding.
 

jmcilhinney

C# Forum Moderator
Staff member
Joined
Apr 23, 2011
Messages
3,134
Location
Sydney, Australia
Programming Experience
10+
Ok suppose the remote ip of my mysql database is 62.1.138.51, how do I use this connection string to connect to it

I have something like this
C#:
Driver={MySQL ODBC 5.2 ANSI Driver};Server=62.1.138.51;Database=myDataBase;
User=myUsername;Password=myPassword;Option=3;
If you are using Connector/Net then why would you use an ODBC connection string? Use a connection string that is intended for Connector/Net.

MySQL Connector/Net Connection Strings - ConnectionStrings.com
 
Top Bottom