Skip to content

Instantly share code, notes, and snippets.

@mbround18
Created November 6, 2017 03:44
Show Gist options
  • Save mbround18/e2c061112d9934abe3ce39f1a1e79e4a to your computer and use it in GitHub Desktop.
Save mbround18/e2c061112d9934abe3ce39f1a1e79e4a to your computer and use it in GitHub Desktop.
using MySql.Data.MySqlClient; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using MySql.Data.MySqlClient; namespace str { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { MySql.Data.MySqlClient.MySqlConnection connect; string MyconnetString; MyconnetString = "server=" + textBox1.Text + ";port=" + textBox2.Text + ";Database=" + textBox3.Text + ";uid=" + textBox4.Text + ";pwd=" + textBox5.Text +"; "; try { connect = new MySql.Data.MySqlClient.MySqlConnection(); connect.ConnectionString = MyconnetString; connect.Open(); if (connect .State == ConnectionState.Open ) { button1.ForeColor = Color.Green; MessageBox.Show("Good"); } connect.Close(); // Thank all ): } catch (MySql.Data.MySqlClient.MySqlException ex) { MessageBox.Show(ex.Message ); } } } }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment