Pre-reqs
First read this post to get ASP.Net to work at x10Hosting
http://forums.x10hosting.com/tutorials/102062-how-get-asp-net-work-x10hosting.html
Use your C Panel to create a database (MySQL Databases) and create tables and data (phpMyAdmin)
Steps
1. Create a bin folder in the root of your public_html directory
2. Get the two MySql dot net connector dlls and place them in the bin folder
http://dev.mysql.com/downloads/connector/net/6.2.html
MySql.Data.dll
MySql.Web.dll
You may already have these on your PC if you have been developing against a MySql database.
Remember you are running ASP.Net on a Linux Mono box so it is cAsE SenSiTive, please ensure the dll names remain the same as they were when you downloaded them.
3. There are a variety of ways to write the asp.net page but the key point is the connection string must use mysql-chopin.x10hosting.com for the server and not localhost which will work in php and drove me nuts for a couple of days.
4. Example 1
This is how I have set mine up and it is working, you will need to edit the connection string to your own database, username and password. Also the SQL statements table name will need changing to your own tablename.
The asp code came from this tutorial - http://townx.org/blog/elliot/using-mysql-asp-net-under-mono-linux
web.config
aspx Page
5. Example 2
thegriff has replied to my queries about this with another example, he has placed the connection string in his web.config file and not bothered with any references.
http://forums.x10hosting.com/programming-help/103929-asp-net-mysql.html#post592093
First read this post to get ASP.Net to work at x10Hosting
http://forums.x10hosting.com/tutorials/102062-how-get-asp-net-work-x10hosting.html
Use your C Panel to create a database (MySQL Databases) and create tables and data (phpMyAdmin)
Steps
1. Create a bin folder in the root of your public_html directory
2. Get the two MySql dot net connector dlls and place them in the bin folder
http://dev.mysql.com/downloads/connector/net/6.2.html
MySql.Data.dll
MySql.Web.dll
You may already have these on your PC if you have been developing against a MySql database.
Remember you are running ASP.Net on a Linux Mono box so it is cAsE SenSiTive, please ensure the dll names remain the same as they were when you downloaded them.
3. There are a variety of ways to write the asp.net page but the key point is the connection string must use mysql-chopin.x10hosting.com for the server and not localhost which will work in php and drove me nuts for a couple of days.
4. Example 1
This is how I have set mine up and it is working, you will need to edit the connection string to your own database, username and password. Also the SQL statements table name will need changing to your own tablename.
The asp code came from this tutorial - http://townx.org/blog/elliot/using-mysql-asp-net-under-mono-linux
web.config
Code:
<?xml version="1.0" ?>
<configuration>
<appSettings />
<connectionStrings />
<system.web>
<customErrors mode="Off" />
</system.web>
</configuration>
<configuration>
<system.web>
<compilation>
<assemblies>
<add assembly="MySql"/>
<add assembly="MySql.Data"/>
</assemblies>
</compilation>
</system.web>
</configuration>
Code:
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="MySql.Data.MySqlClient" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>CD cat</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script runat="server">
private void Page_Load(Object sender, EventArgs e)
{
string connectionString = "server=mysql-chopin.x10hosting.com;Database=MyDatabase;userid=MyUserId;password=MyPassword;Pooling= false;";
MySqlConnection dbcon = new MySqlConnection(connectionString);
dbcon.Open();
MySqlDataAdapter adapter = new MySqlDataAdapter("SELECT * FROM CDs", dbcon);
DataSet ds = new DataSet();
adapter.Fill(ds, "result");
dbcon.Close();
dbcon = null;
ArtistsControl.DataSource = ds.Tables["result"];
ArtistsControl.DataBind();
}
</script>
</head>
<body>
<h1>Artists</h1>
<asp:DataGrid runat="server" id="ArtistsControl" />
</body>
</html>
thegriff has replied to my queries about this with another example, he has placed the connection string in his web.config file and not bothered with any references.
http://forums.x10hosting.com/programming-help/103929-asp-net-mysql.html#post592093