Advertisement
Guest User

Untitled

a guest
Mar 26th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.94 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using MySql.Data;
  11. using MySql.Data.MySqlClient;
  12.  
  13. namespace UtentiBaseRedmineUpdater
  14. {
  15.     public partial class Form1 : Form
  16.     {
  17.         private MySqlConnection connection;
  18.         private string server;
  19.         private string database;
  20.         private string user;
  21.         private string password;
  22.         private string port;
  23.         private string connectionString;
  24.  
  25.  
  26.         public Form1()
  27.         {
  28.             InitializeComponent();
  29.          
  30.  
  31.             server = "89.46.111.65";
  32.             database = "Sql1212242_1";
  33.             user = "Sql1212242";
  34.             password = "rrg7w60de9";
  35.             port = "3306";
  36.  
  37.         }
  38.  
  39.  
  40.  
  41.         // cnn.ConnectionString = "Server=52.28.70.223,3306;Database=redmine_alteain_02;User Id=redmine_alteain_02;Password=T6MJzcUyqER7K6sS;";
  42.         // connectionString = "SERVER=" + "52.28.70.223,3306" + ";" + "DATABASE=" + "redmine_alteain_02" + ";" + "UID=" + "redmine_alteain_02" + ";" + "PASSWORD=" + "T6MJzcUyqER7K6sS" + ";
  43.          
  44.         private void button1_Click(object sender, EventArgs e)
  45.         {
  46.             connectionString = String.Format("Server={0};Database={2};User Id={3};Password={4} ", server,port,database, user, password);
  47.            connection = new MySqlConnection(connectionString);
  48.             //  connection = new MySqlConnection("datasource=52.28.70.223;port=3306;username=redmine_alteain_02;password=T6MJzcUyqER7K6sS");
  49.  
  50.  
  51.             try
  52.             {
  53.                 connection.Open();
  54.  
  55.                 MessageBox.Show("successful connection");
  56.  
  57.                 connection.Close();
  58.             }
  59.             catch (MySqlException ex)
  60.             {
  61.                 MessageBox.Show(ex.Message);
  62.             }
  63.         }
  64.     }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement