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 dataentry
- {
- public partial class UserLogin : Form
- {
- public UserLogin()
- {
- InitializeComponent();
- }
- SqlConnection asdf = new SqlConnection("Data Source=.;Initial Catalog=dataentry;Integrated Security=True;Pooling=False");
- private void button11_Click(object sender, EventArgs e)
- {
- SqlDataAdapter asd = new SqlDataAdapter("select status from login where UserName='" + username.Text+ "' and pass='"+password.Text+"'", asdf);
- DataTable dt = new DataTable();
- asd.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();
- }
- }
- }
- private void username_TextChanged(object sender, EventArgs e)
- {
- }
- }
- }
Facebook Comment