LOG IN
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 System.Data.SqlClient;
namespace login
{
public partial class formlogin : Form
{
public formlogin()
{
InitializeComponent();
}
private void btnLogin_Click(object sender, EventArgs e)
{
string constr = "data
source=ACER-PC\\SQLEXPRESS;database = hr;integrated security = SSPI";
string query="Select *from
tblEmployees Where id='"+txtUsername.Text.Trim()+"'and name='"+textPassword.Text.Trim()+"'";
SqlDataAdapter sda=new SqlDataAdapter(query,constr);
DataTable dtbl=new DataTable();
sda.Fill(dtbl);
if(dtbl.Rows.Count ==1)
{
frmMain obj=new frmMain();
this.Hide();
obj.Show();
}
else{
MessageBox.Show("error");
}
}
}
}
Tidak ada komentar:
Posting Komentar