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.Threading.Tasks;
- using System.Windows.Forms;
- using MySql.Data.MySqlClient;
- namespace RERU
- {
- public partial class Form4 : Form
- {
- public Form4()
- {
- InitializeComponent();
- }
- public static string connectorString = "server = localhost;Database=reru;User ID=root;Password=";
- private void Form4_Load(object sender, EventArgs e)
- {
- this.TopMost = true;
- }
- private void button1_Click(object sender, EventArgs e)
- {
- string query = $"INSERT INTO act (act.act_Name,act.act_Date,act.act_Exp,act.act_Type,act.act_Term,act.act_Year) VALUES ('{textBox1.Text}','{dateTimePicker1.Text}','{dateTimePicker2.Text}','{comboBox1.Text}','{comboBox2.Text}/{maskedTextBox1.Text}','{checkedListBox1.Text}')";
- MessageBox.Show(query);
- MySqlConnection Conn = new MySqlConnection(connectorString);
- //this.Hide();
- //(new Form2()).Show();
- try
- {
- Conn.Open();
- MySqlCommand myCommand = new MySqlCommand(query, Conn);
- myCommand.ExecuteNonQuery();
- MessageBox.Show("Added");
- Conn.Close();
- }
- catch(Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement