+ Reply to Thread
Results 1 to 3 of 3

Thread: Remote SQL Connection

  1. #1

    Remote SQL Connection

    Hey , i want to know how to remotely connect to a SQL database , how can i do that ?
    Last edited by csharpmaster; 11-11-2012 at 10:00 AM.

  2. #2
    Junior Member
    Join Date
    Dec 2011
    Posts
    1
    That's great. Thanks for posting!

  3. #3
    Junior Member
    Join Date
    Jan 2012
    Posts
    35
    With the use of a dll called MYSQLCONNECTOR.DLL found at http://dev.mysql.com , so you need to download the .dll and add it to your application reference and then :
    Code:
    using MySql.Data.MySqlClient;
    MYSQCLIENT is typically the same as the normal System.Data.SqlClient as you will see in just a moment :
    Code:
                //connectionstring          
                MySqlConnection c = new MySqlConnection("server=XXX.XXX.XXX.XXX; database=db_name; uid=username; pwd=basemhosam;");
                // define a dataset to display data
                DataSet ds = new DataSet();
                // MySqlDataAdapter for commands
                MySqlDataAdapter msd = new MySqlDataAdapter();
                // simple sql query
                msd.SelectCommand = new MySqlCommand("SELECT * FROM table", c);
                // open connection
                c.Open();
                // fill the data into dataset
                msd.Fill(ds);
                // i already put a datagrid on my application
                dataGridView1.DataSource = ds.Tables[0];
                // execute query
                msd.SelectCommand.ExecuteNonQuery();
                // close connection
                c.Close();

+ Reply to Thread

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts