SHARE
TWEET

Untitled

a guest Mar 29th, 2019 119 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7. using System.Data.SqlClient;
  8. using System.Data;
  9.  
  10. namespace loginfunctietest
  11. {
  12.     public partial class login : System.Web.UI.Page
  13.     {
  14.         protected void Page_Load(object sender, EventArgs e)
  15.         {
  16.             lblErrorMsg.Visible = false;
  17.         }
  18.  
  19.         protected void btnLogin_Click(object sender, EventArgs e)
  20.         {
  21.             using (SqlConnection sqlCon = new SqlConnection(@"Data Soure=(local)\sqle2012;inital Catalog=LoginDB;IntegratedSecurity=True"))
  22.             {
  23.                 sqlCon.Open();
  24.                 string query = "SELECT COUNT(1) FROM gebruiker WHERE Naam=@Naam AND Wachtwoord=@Wachtwoord";
  25.                 SqlCommand sqlCmd = new SqlCommand(query, sqlCon);
  26.                 sqlCmd.Parameters.AddWithValue("@Naam",txtNaam.Text.Trim());
  27.                 sqlCmd.Parameters.AddWithValue("@",txtWachtwoord.Text.Trim());
  28.                 int count = Convert.ToInt32(sqlCmd.ExecuteScalar());
  29.                 if(count ==1 )
  30.                 {
  31.                     Session["Naam"] = txtNaam.Text.Trim();
  32.                     Response.Redirect("dash.aspx");
  33.                 }
  34.                 else
  35.                 {
  36.                     lblErrorMsg.Visible = true;
  37.                 }
  38.             }
  39.         }
  40.     }
  41. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top