0% found this document useful (0 votes)
35 views1 page

Confer M

This document contains C# code for a web form that authenticates a user login by comparing the entered password to the password stored in a SQL database for the given username. The code opens a SQL connection and executes a command to select the password from the database table where the username matches the entered username. It then compares the retrieved password to the entered password and displays a welcome message if they match, or a failure message if they do not match.

Uploaded by

ssnurudeen
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views1 page

Confer M

This document contains C# code for a web form that authenticates a user login by comparing the entered password to the password stored in a SQL database for the given username. The code opens a SQL connection and executes a command to select the password from the database table where the username matches the entered username. It then compares the retrieved password to the entered password and displays a welcome message if they match, or a failure message if they do not match.

Uploaded by

ssnurudeen
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

using using using using using using using

System; System.Collections.Generic; System.Linq; System.Web; System.Web.UI; System.Web.UI.WebControls; System.Data.SqlClient;

namespace refer { public partial class hello : System.Web.UI.Page { SqlConnection con; SqlCommand com; SqlDataReader reader; protected void Page_Load(object sender, EventArgs e) { con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=I:\vs1\lessons\refer\refer\App_Data\Database2.mdf;In tegrated Security=True;User Instance=True"); } protected void Button1_Click(object sender, EventArgs e) { con.Open(); com = new SqlCommand("select Password from table2 where Username='"+usernametxt.Text +"'", con); reader = com.ExecuteReader(); //Label4.Text = reader[0].ToString(); reader.Read(); if (reader[0].ToString() != TextBox2.Text) { Label3.Visible = true; } else { Label4.Text = " welcome " + usernametxt.Text; } } } }

You might also like