+ Reply to Thread
Results 1 to 5 of 5

Thread: How to get ASP.Net to work with MySql at x10Hosting

  1. #1
    spangeman is offline x10Hosting Member spangeman is an unknown quantity at this point
    Join Date
    Oct 2009
    Posts
    6

    How to get ASP.Net to work with MySql at x10Hosting

    Pre-reqs
    First read this post to get ASP.Net to work at x10Hosting
    http://forums.x10hosting.com/tutoria...10hosting.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-m...der-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>
    aspx Page
    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>
    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/program...tml#post592093

  2. #2
    tvmtuan is offline x10Hosting Member tvmtuan is an unknown quantity at this point
    Join Date
    Nov 2009
    Posts
    1

    Re: How to get ASP.Net to work with MySql at x10Hosting

    Thank you for your post, but when I ping mysql-chopin.x10hosting.com, there's no reply. When I ping mysql.x10hosting.com, I received replies. So I put mysql.x10hosting.com into server in connection string. My Connection string is something like this:
    Code:
    server=mysql.x10hosting.com;Database=DBName;userid=username;password=password;Pooling=false
    When I run my page, I received an exception Unable to connect to any of the specified MySQL hosts. Does anyone have a solution for this^^
    Last edited by tvmtuan; 11-29-2009 at 02:55 PM. Reason: Automerged Doublepost

  3. #3
    misson is offline Community Advocate misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,391

    Re: How to get ASP.Net to work with MySql at x10Hosting

    Quote Originally Posted by tvmtuan View Post
    My Connection string is something like this:
    Code:
    server=mysql.x10hosting.com;Database=DBName;userid=username;password=password;Pooling=false
    The server name should be "localhost"; a search on the forums turns up many threads containing this information (admittedly, alongside threads that don't have the information with that particulary query).
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  4. #4
    zegnhabi's Avatar
    zegnhabi is offline x10Hosting Member zegnhabi is an unknown quantity at this point
    Join Date
    Jul 2009
    Location
    On The Net
    Posts
    42

    Re: How to get ASP.Net to work with MySql at x10Hosting

    Asi es la solucion que propone el compañero es valida y si jala, jeje
    Yo Soy SQLero, ¿Y Tú?


  5. #5
    linearity is offline x10Hosting Member linearity is an unknown quantity at this point
    Join Date
    Jun 2008
    Posts
    1

    I just can't get it to work, what am I doing wrong???

    I have tried to follow this tutorial, but I keep getting and error that says: "Unable to connect to any of the specified MySQL hosts." I have placed the connector dlls into a bin folder in public_html, and if I comment out the line with the call dbConn.Open() the function executes. What am I doing wrong? I am trying to follow the example as shown at http://www.mono-project.com/MySQL, and if I can get the db to open, I will start messing around with queries, but it won't open.

    Here is my web.config

    <?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>

    Here is my Default.aspx.cs file

    using System;
    using System.Data;
    using System.Configuration;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using MySql.Data.MySqlClient;

    public partial class _Default : System.Web.UI.Page
    {
    protected void Page_Load(object sender, EventArgs e)
    {
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
    string connectionString = "Server=mysql-chopin.x10hosting.com;" +
    "Database=xxx;" +
    "User ID=xxx;" +
    "Password=xxx;" +
    "Pooling= false;";

    IDbConnection dbcon;
    dbcon = new MySqlConnection(connectionString);
    dbcon.Open();

    dbcon.Close();
    dbcon = null;
    }
    }

+ Reply to Thread

Similar Threads

  1. how to host Asp.net pages in free x10hosting
    By compguyy in forum Free Hosting
    Replies: 3
    Last Post: 09-15-2009, 07:20 PM
  2. Using ASP.Net on X10Hosting Space
    By owner83 in forum Programming Help
    Replies: 2
    Last Post: 02-05-2009, 11:54 AM
  3. MySQL Conection Remota [De x10hosting a X]
    By Akihiko0 in forum Soporte
    Replies: 2
    Last Post: 09-29-2007, 10:31 PM
  4. Replies: 6
    Last Post: 09-28-2006, 04:52 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers