C# Code For Beginners (Part 4)

Update MySql Database Using Textbox

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 Blog4
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string con = "server=localhost;user id=root;password=;database=blog";
            string query = "Update example set Item_Name = '"+textBox2.Text+"' where Item_Code = '"+textBox1.Text+"'";
            MySqlConnection conn = new MySqlConnection(con);
            MySqlCommand command = new MySqlCommand(query,conn);
            MySqlDataReader reader;
            conn.Open();
            reader = command.ExecuteReader();
            MessageBox.Show("Update ..!");
            conn.Close();
        }
    }
}


output 



Video



Comments

Popular posts from this blog

C# Analog Clock

Basic Prolog (List)

SOLID Principles