Thursday, November 12, 2015

C# - Connect To Cpanel MySql Database Remotely In C#









using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using MySql.Data.MySqlClient;

namespace MySqlConn
{
    public partial class Form1 : Form
    {
        MySqlConnection conn;
        string connString;
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            connString = "SERVER= 127.0.0.1;PORT=3306;DATABASE=database_name;UID=user;PASSWORD=pass;";
            try
            {
                conn = new MySqlConnection();
                conn.ConnectionString = connString;
                conn.Open();
                MessageBox.Show("connection success");

                string query = "SELECT * FROM employee_data";
                //Create Command
                MySqlCommand cmd = new MySqlCommand(query, conn);
                //Create a data reader and Execute the command
                MySqlDataReader dataReader = cmd.ExecuteReader();

                //Read the data and store them in the list
                while (dataReader.Read())
                {
                    Console.WriteLine(dataReader["id"] + "");
                    Console.WriteLine(dataReader["name"] + "");
                    Console.WriteLine(dataReader["surname"] + "");
                    Console.WriteLine(dataReader["age"] + "");
                }
                conn.Close();
            }
            catch (MySql.Data.MySqlClient.MySqlException ex)
            {
                MessageBox.Show(ex.Message);
            }

        }
    }
}
















































Connect C# to MySQL
How to Connect to MySQL Using C#
c# - How to connect to MySQL Database?
MySQL .NET With C#
C# Windows Form Application Mysql Connection
c# - How can I connect to MySQL from windows forms?
Using Visual C# Windows Forms with MySQL
C# Programming for beginners: How to connect MySQL Database
Windows Form Application using Mysql Server 
Connect MySQL from C# Windows Forms 
mysql problem to connect with windows form c#
C# Windows Form Application Mysql Connection
Mysql And Visual C# 2010 Windows Form Application
MySQL :: Connecting to MySQL with a Windows Form application
C# Form textbox string into SQL Database
visual c# CLR windows form application and mysql
assembly reference not working in C# script
Trying to connect to MySQL from C# application 
mysql and C# window form application
How to connect MySQL using C#?‎
IT Certification Category (English)640x480

Partner Sites

VideoToGifs.com

EasyOnlineConverter.com

SqliteTutorials.com


Top Online Courses From ProgrammingKnowledge

Python Course http://bit.ly/2vsuMaS
Java Coursehttp://bit.ly/2GEfQMf
Bash Coursehttp://bit.ly/2DBVF0C
Linux Coursehttp://bit.ly/2IXuil0
C Course http://bit.ly/2GQCiD1
C++ Coursehttp://bit.ly/2V4oEVJ
PHP Coursehttp://bit.ly/2XP71WH
Android Coursehttp://bit.ly/2UHih5H
C# Coursehttp://bit.ly/2Vr7HEl
JavaFx Coursehttp://bit.ly/2XMvZWA
NodeJs Coursehttp://bit.ly/2GPg7gA
Jenkins Course http://bit.ly/2Wd4l4W
Scala Coursehttp://bit.ly/2PysyA4
Bootstrap Coursehttp://bit.ly/2DFQ2yC
MongoDB Coursehttp://bit.ly/2LaCJfP
QT C++ GUI Coursehttp://bit.ly/2vwqHSZ