+62 852-4056-7490 •

Artikel

C# - Register Form Menggunakan Database Mysql

ITO 3 Comments Mei 17, 2018
img

Register.cs

using System;
using System.Windows.Forms;

namespace LoginProject
{
    public partial class Register : Form
    {
        public Register()
        {
            InitializeComponent();
        }

        private void X_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void Login_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void BTN_Create_Click(object sender, EventArgs e)
        {
            if (!(Username.Text.Equals("") || Password.Text.Equals("")))
            {
                if(koneksi.query("INSERT INTO user (Username, Password) VALUES('" + Username.Text + "','" + Password.Text + "')"))
                {
                    MessageBox.Show("Register Succes");
                    Close();
                }
                else
                {
                    MessageBox.Show("Register Not Succes");
                }
            }
            else
            {
                MessageBox.Show("Username and Password are required");
            }
        }
    }
}

 

koneksi.cs

using MySql.Data.MySqlClient;
using System.Data;

namespace LoginProject
{
    class koneksi
    {
        static MySqlConnection konek = new MySqlConnection("server=localhost;uid=root;database=db_login;password=;");
        static MySqlCommand cmd;

        public static bool query(string qry)
        {
            try
            {
                konek.Open();
                cmd = new MySqlCommand(qry, konek);
                cmd.ExecuteNonQuery();
                return true;
            }
            catch
            {
                return false;
            }
            finally
            {
                konek.Close();
            }
        }
    }
}

 

Tonton Videonya di http://youtu.be/wCDtDWpFAI8

Artikel Terkait http://dcc-dp.id/artikel/detail/5994/c#---form-login-menggunakan-database-mysql

 

 


Tags: windows desktop database c#

3 Comments

reply

John Doe

June 29, 2014 - 11:23 Proin eget tortor risus. Cras ultricies ligula sed magna dictum porta. Pellentesque in ipsum id orci porta dapibus. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
reply

Diana Doe

June 29, 2014 - 11:23 Proin eget tortor risus. Cras ultricies ligula sed magna dictum porta. Pellentesque in ipsum id orci porta dapibus. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
reply

Melissa Doe

June 29, 2014 - 11:23 Proin eget tortor risus. Cras ultricies ligula sed magna dictum porta. Pellentesque in ipsum id orci porta dapibus. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Peter Doe

June 29, 2014 - 11:23 Proin eget tortor risus. Cras ultricies ligula sed magna dictum porta. Pellentesque in ipsum id orci porta dapibus. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Leave a reply Your email address will not be published.


Allowed HTML tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Inappropriate and irrelevant comments will be removed at an admin's discretion.
Your email is used for verification purposes only, it will never be shared.