Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Data.SqlClient;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- namespace Assignment_4__2_
- {
- public partial class DefualtforLogin : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- }
- protected void submitButton_Click(object sender, EventArgs e)
- {
- SqlConnection con = new SqlConnection();
- con.ConnectionString = "Data Source=itksqlexp8; ; Initial Catalog=xchenne_ConservationSchool;Integrated Security=True;Pooling=False";
- //Int32 verify;
- string query1 = "Select * from verification where username='" + usernameTextBox.Text + "' and password='" + passwordTextBox.Text + "' ";
- // SqlCommand cmd1 = new SqlCommand(query1, con);
- System.Data.SqlClient.SqlCommand comm = new System.Data.SqlClient.SqlCommand(query1, con);
- // create a sqldatabase reader which will execute the above command to get the values from sqldatabase
- System.Data.SqlClient.SqlDataReader reader;
- // open a connection with sqldatabase
- con.Open();
- // execute sql command and store a return values in reade
- reader = comm.ExecuteReader();
- // check if reader hase any value then return true otherwise return false
- if (reader.Read())
- errorLabel.Text = "Hello, " + usernameTextBox.Text;
- else
- errorLabel.Text = "Please enter a valid username and password";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement