Advertisement
icorrelate

Remote Mysql Tutorial

Apr 22nd, 2017
1,695
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.21 KB | None | 0 0
  1. using MySql.Data.MySqlClient;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Windows.Forms;
  10.  
  11. namespace RemoteMysql
  12. {
  13.     public partial class Form1 : Form
  14.     {
  15.         public Form1()
  16.         {
  17.             InitializeComponent();
  18.         }
  19.  
  20.         private void button1_Click(object sender, EventArgs e)
  21.         {
  22.             string connetionString = null;
  23.             string server = "31.170.164.42";
  24.             string database = "u545502386_data";
  25.             string username = "u545502386_user";
  26.             string password = "randompassword";
  27.  
  28.  
  29.             MySqlConnection cnn;
  30.             connetionString = "server="+server+";database="+database+";uid="+username+";pwd="+password+";";
  31.             cnn = new MySqlConnection(connetionString);
  32.             try
  33.             {
  34.                 cnn.Open();
  35.                 MessageBox.Show("Connection Open ! ");
  36.                 cnn.Close();
  37.             }
  38.             catch (Exception ex)
  39.             {
  40.                 MessageBox.Show("Can not open connection ! " + ex.Message.ToString());
  41.             }
  42.         }
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement