Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Connecting to MySQL from PC

Connecting to MySQL from PC

Scheduled Pinned Locked Moved C#
databasemysqlvisual-studiosysadminquestion
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MarkB777
    wrote on last edited by
    #1

    Hi, Just wondering... I downloaded the MySQLConnection library for VS. I'm using the code below to try and connect to a MySQL database on my webpage. It's not working though :( Anyone tried doing this before? string server = "Server=http://www.somepage.org.nz;Database=somedatabase;Uid=myusername;Pwd=mypassword"; MySqlConnection con = null; try { con = new MySqlConnection(server); con.Open(); this.label1.Text = con.State.ToString(); } catch (Exception ex) { this.label1.Text = ex.Message; }

    Mark Brock "We're definitely not going to make a G or a PG version of this. It's not PillowfightCraft." -- Chris Metzen

    L S D 3 Replies Last reply
    0
    • M MarkB777

      Hi, Just wondering... I downloaded the MySQLConnection library for VS. I'm using the code below to try and connect to a MySQL database on my webpage. It's not working though :( Anyone tried doing this before? string server = "Server=http://www.somepage.org.nz;Database=somedatabase;Uid=myusername;Pwd=mypassword"; MySqlConnection con = null; try { con = new MySqlConnection(server); con.Open(); this.label1.Text = con.State.ToString(); } catch (Exception ex) { this.label1.Text = ex.Message; }

      Mark Brock "We're definitely not going to make a G or a PG version of this. It's not PillowfightCraft." -- Chris Metzen

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      http://www.functionx.com/mysqlnet/csharp/Lesson02.htm[^] probably using : 'myusername' and 'mypassword'

      1 Reply Last reply
      0
      • M MarkB777

        Hi, Just wondering... I downloaded the MySQLConnection library for VS. I'm using the code below to try and connect to a MySQL database on my webpage. It's not working though :( Anyone tried doing this before? string server = "Server=http://www.somepage.org.nz;Database=somedatabase;Uid=myusername;Pwd=mypassword"; MySqlConnection con = null; try { con = new MySqlConnection(server); con.Open(); this.label1.Text = con.State.ToString(); } catch (Exception ex) { this.label1.Text = ex.Message; }

        Mark Brock "We're definitely not going to make a G or a PG version of this. It's not PillowfightCraft." -- Chris Metzen

        S Offline
        S Offline
        spalanivel
        wrote on last edited by
        #3

        Hi, 1) First you need to add reference MySql.Data to your application. 2) Then //create a new mysqlconnection MySqlConnection mycon = new MySqlConnection("datasource=localhost;username=root;password=pwd;database=project"); //create a mysql DataAdapter MySqlDataAdapter myadp = new MySqlDataAdapter("select * from FAB", mycon); //create a dataset DataSet myds = new DataSet(); //now fill and bind the DataGrid myadp.Fill(myds, "empinfo"); dataGridView1.DataSource = myds.Tables["empinfo"].DefaultView; I have used with windows application. Try this. Regards, Subbu

        1 Reply Last reply
        0
        • M MarkB777

          Hi, Just wondering... I downloaded the MySQLConnection library for VS. I'm using the code below to try and connect to a MySQL database on my webpage. It's not working though :( Anyone tried doing this before? string server = "Server=http://www.somepage.org.nz;Database=somedatabase;Uid=myusername;Pwd=mypassword"; MySqlConnection con = null; try { con = new MySqlConnection(server); con.Open(); this.label1.Text = con.State.ToString(); } catch (Exception ex) { this.label1.Text = ex.Message; }

          Mark Brock "We're definitely not going to make a G or a PG version of this. It's not PillowfightCraft." -- Chris Metzen

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          MarkBrock wrote:

          string server = "Server=http://www.somepage.org.nz;

          That's not going to work. You cannot access a database over the HTTP protocol. Your corrected string should look more like:

          Server=someSqlServer.somepage.org.nz;

          But, that's not likely to work either. Either the MySQL server has to be exposed directly to the Internet (a REALLY STUPID thing to do), or that site has to expose some other method of interaction with the database, such as a Web Service.

          A guide to posting questions on CodeProject[^]
          Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
               2006, 2007, 2008
          But no longer in 2009...

          L M 2 Replies Last reply
          0
          • D Dave Kreskowiak

            MarkBrock wrote:

            string server = "Server=http://www.somepage.org.nz;

            That's not going to work. You cannot access a database over the HTTP protocol. Your corrected string should look more like:

            Server=someSqlServer.somepage.org.nz;

            But, that's not likely to work either. Either the MySQL server has to be exposed directly to the Internet (a REALLY STUPID thing to do), or that site has to expose some other method of interaction with the database, such as a Web Service.

            A guide to posting questions on CodeProject[^]
            Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                 2006, 2007, 2008
            But no longer in 2009...

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            Dave Kreskowiak wrote:

            ...exposed directly to the Internet (a REALLY STUPID thing to do)...

            Check out the CodeProject forum Guidelines[^] The original soapbox 1.0 is back![^]

            1 Reply Last reply
            0
            • D Dave Kreskowiak

              MarkBrock wrote:

              string server = "Server=http://www.somepage.org.nz;

              That's not going to work. You cannot access a database over the HTTP protocol. Your corrected string should look more like:

              Server=someSqlServer.somepage.org.nz;

              But, that's not likely to work either. Either the MySQL server has to be exposed directly to the Internet (a REALLY STUPID thing to do), or that site has to expose some other method of interaction with the database, such as a Web Service.

              A guide to posting questions on CodeProject[^]
              Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                   2006, 2007, 2008
              But no longer in 2009...

              M Offline
              M Offline
              MarkB777
              wrote on last edited by
              #6

              Thought that might be the case, cheers Dave.

              Mark Brock "We're definitely not going to make a G or a PG version of this. It's not PillowfightCraft." -- Chris Metzen

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups