This is A C# Practice code:
- 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 System.Data.SqlClient;
- namespace AuthenticationLogin
- {
- public partial class Login : Form
- {
- public Login()
- {
- InitializeComponent();
- }
- SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=dataentry;Integrated Security=True;Pooling=False");
- private void button1_Click(object sender, EventArgs e)
- {
- SqlDataAdapter sdf = new SqlDataAdapter("select status from login where username='"+textBox1.Text+"' and Pass='"+textBox2.Text+"' ", con);
- DataTable dt = new DataTable();
- sdf.Fill(dt);
- if(dt.Rows.Count==1)
- {
- if(dt.Rows[0][0].ToString()=="Master")
- {
- Form1 f1 = new Form1(dt.Rows[0][0].ToString());
- f1.Show();
- }
- else if (dt.Rows[0][0].ToString() =="Student")
- {
- Student f1 = new Student(dt.Rows[0][0].ToString());
- f1.Show();
- }
- else if (dt.Rows[0][0].ToString() == "Client")
- {
- Client f1 = new Client(dt.Rows[0][0].ToString());
- f1.Show();
- }
- }
- }
- }
- }
Facebook Comment