Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 Database_Buddy
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void button3_Click(object sender, EventArgs e)
- {
- textBox1.Text = "";
- textBox2.Text = "";
- textBox3.Text = "";
- textBox4.Text = "";
- textBox5.Text = "Query to be run";
- }
- private void button1_Click(object sender, EventArgs e)
- {
- if (textBox1.Text == "")
- {
- // run code later
- }
- else
- {
- string host = textBox1.Text;
- string username = textBox2.Text;
- string name = textBox3.Text;
- string password = textBox4.Text;
- string query = textBox5.Text;
- if (query == "")
- {
- // we're going to show the user the result
- textBox6.Text = "Query was left empty";
- }
- else
- {
- MySqlConnection connection = new MySqlConnection("server=" + host + ";database=" + name + ";uid=" + username + ";password=" + password + "");
- MySqlCommand command = connection.CreateCommand();
- connection.Open();
- MySqlCommand command2 = new MySqlCommand("" + query + "", connection);
- textBox6.Text = "Error connection";
- command2.ExecuteNonQuery();
- connection.Close();
- textBox6.Text = "Query should be complete!";
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement