Assignment 2 PDF
Assignment 2 PDF
Assignment 2 PDF
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 Assignment2
{
public partial class Form1 : Form
{
//Initializing SQL connection
public Form1()
{
InitializeComponent();
// The link to our local MSSQL Database
con.ConnectionString = @"Data Source = (localdb)\MSSQLLocalDB; Initial Catalog =
master; Integrated Security = True";
con.Open();
com.Connection = con;
com.CommandText = "SELECT * FROM Users";
SqlDataReader dr = com.ExecuteReader();
if (dr.Read())
{
//Checking If Credentials Provided by user are correct and display necessary
message
if (textBox1.Text.Equals(dr["usename"].ToString())&&
textBox2.Text.Equals(dr["password"].ToString()))
{
}
else
{
string username = dr["usename"].ToString();
MessageBox.Show(username + "Cant Login", "Error ", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
con.Close();
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace Assignment2
{
public partial class Projects : Form
{
// The link to our local MSSQL Database
string connectionString = @"Data Source = (localdb)\MSSQLLocalDB; Initial Catalog =
master; Integrated Security = True";
public Projects()
{
InitializeComponent();
}
sqlCon.Close();
}
}
}
}