+ Reply to Thread
Results 1 to 3 of 3

Thread: MySQL <-> VB.net issues

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

    MySQL <-> VB.net issues

    Hello everyone,

    I'm trying to set a connection between my vb.net application and my MySQL located on mysql-starka.x10hosting.com
    The issue is, that I can't seem to find a good tutorial explaining it, and if i do, he asks me for IP, port etc. which I don't have (or see on the phpmyadmin).

    If anyone knows how to do it, please respond a.s.a.p. since I really need it.

    Yours sincerely, Anasky.

  2. #2
    thegriff is offline x10Hosting Member thegriff is an unknown quantity at this point
    Join Date
    Sep 2009
    Posts
    14

    Re: MySQL <-> VB.net issues

    Tutorials do seem a bit useless - I had to work out most of it myself, with bits of google everywhere.

    You have the mySql address, which is good: mysql-starka.x10hosting.com but it won't work - see later under web.config!

    Have you got the mySql Connector? (the bit that comes in two ASP.NET assemblies mysql.Data.dll and mysql.web.dll) If so, then copy the two DLLs to the "/public_html/bin" folder in your webspace.

    Have you set up a database in phpMyAdmin? If not, create a simple on for testing.

    Have you set up a user for your databases, and allowed them full access rights to your test database? (phpMyAdmin again).

    Edit your web.config on the server, and make it look lijke this:
    Code:
    <?xml version="1.0" ?>
    <configuration>
      <appSettings />
      <connectionStrings>
        <add name="LoginDatabase" connectionString="server=mysql-chopin.x10hosting.com;database=XXX_testing;user id=DATABASEUSER;password=PASSWORD"/>
      </connectionStrings>
      <system.web>
        <customErrors mode="Off" />
      </system.web>
      <system.net>
        <mailSettings>
          <smtp deliveryMethod="network">
            <network port="26" />
          </smtp>
        </mailSettings>
      </system.net>
    </configuration>
    Replace the XXX with your x10hosting userid - I am guessing "starka", replace the DATABASEUSER and PASSWORD with the user info you set up in phpMyAdmin

    The following code is C#, but it should be easy to translate to VB:
    Code:
    
    string strConnect = ConfigurationManager.ConnectionStrings["LoginDatabase"].ConnectionString;
    MySqlCommand cmd = new MySqlCommand("SELECT Role FROM UserInfo WHERE userID = @ID");
    cmd.Parameters.AddWithValue("@ID", userId);
    MySqlDataReader reader = null;
    try
    {
    cmd.Connection = new MySqlConnection(strConnect);
    cmd.Connection.Open();
    reader = cmd.ExecuteReader();
    if (reader.Read())
    {
    this.role = (UserRole)reader["Role"];
    }
    catch (Exception ex)
    {
    thrownewException(cmd.CommandText + "\n" +
    ex.Message, ex);
    }
    finally
    {
    if (reader != null)
    {
    reader.Close();
    }
    if (cmd.Connection != null)
    {
    cmd.Connection.Close();
    }
    }
    
    This is lifted directly from a working routine, so it should be fine.

    Make sure you have installed mySQl on your development machine, and set the connection string in the local web.config to select that (probably via "localhost" rather than "mysql-chopin.x10...")

    Any probs, let me know!
    No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.


    FOR SALE: Bargain! Large supply of slightly used '0's and '1's. Can be delivered electronically. Special rates for bulk purchases!

  3. #3
    xav0989's Avatar
    xav0989 is offline Community Public Relation xav0989 is just really nice
    Join Date
    Jul 2008
    Location
    ifk
    Posts
    4,438

    Re: MySQL <-> VB.net issues

    Simply to add some to the previous post, for the database creation, do not use phpmyadmin, but go directly through cPanel. As for the database username, use cPanel-username_database-username
    Xavier L | Community Public Relations Manager (Free Hosting Support)
    █ Yes, my position is too cool to even exist!
    How am I helping? Rate this post by clicking the icon below! (this is even better than "liking" a post)
    Terms of Service | Acceptable Use Policy | x10Hosting Wiki

+ Reply to Thread

Similar Threads

  1. New Site-Suggestions?
    By mnoutside in forum Review My Site
    Replies: 9
    Last Post: 08-27-2008, 07:01 AM
  2. MySQL issues..
    By pulledteeth in forum Free Hosting
    Replies: 2
    Last Post: 07-09-2008, 01:52 AM
  3. info discrepancy and MySQL issues
    By hathehariken in forum Free Hosting
    Replies: 5
    Last Post: 04-10-2008, 09:37 PM
  4. Joomla and MySQL
    By jtaah in forum Scripts & 3rd Party Apps
    Replies: 11
    Last Post: 04-10-2008, 06:28 PM

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