Using ADO.Net to Build a Login System Dr. Ron Eaglin.

Slides:



Advertisements
Similar presentations
Stored procedures and views You can see definitions for stored procedures and views in the demo databases but you can’t change them. For views, expand.
Advertisements

Chapter 10 Database Applications Copyright © 2011 by The McGraw-Hill Companies, Inc. All Rights Reserved. McGraw-Hill.
Chapter 12: ADO.NET and ASP.NET Programming with Microsoft Visual Basic.NET, Second Edition.
Compunet Corporation Programming with Visual Studio.NET GUI Week 13 Tariq Aziz and Kevin Jones.
Visual Studio 2005 Using the DataGridView Control V. Matos Cleveland State University.
VB.NET Database Tools ISYS Net Applications OLE DB Provider OLE DB Data Source OLE DB Provider ODBC Data Source SQL Server Data Source SQL Server.Net.
Introduction to Data Adapter. A Simplified View of ADO.Net Objects Ado.Net Data Provider Connection Adapter Command Reader Dataset Data Consumer WinForm.
.Net Overview Data Driven Desktop and Web Applications using VB.Net and ASP.Net, C#.Net or J#.Net.
Introduction to ADO.Net, VB.Net Database Tools and Data Binding ISYS 512.
VB.NET Database Tools ISYS 573. Microsoft Universal Data Access ODBC: Open Database Connectivity –A driver manager –Used for relational databases OLE.
Coding ADO.NET Objects: Connection, Command, DataReader.
Introduction to ADO.Net, VB.Net Database Tools and Data Binding ISYS 512.
ASP.NET Programming with C# and SQL Server First Edition Chapter 8 Manipulating SQL Server Databases with ASP.NET.
Stored Procedures Dr. Ralph D. Westfall May, 2009.
Microsoft Visual Basic 2005 CHAPTER 8 Using Procedures and Exception Handling.
Visual Basic Fundamental Concepts. Integrated Development Enviroment Generates startup form for new project on which to place controls. Features toolbox.
Visual Basic 2008 Express Edition The IDE. Visual Basic 2008 Express The Start Page Recent Projects Open an existing project Create a New Project.
Microsoft Azure Introduction ISYS 512. Microsoft Azure Microsoft Azure is a cloud.
Microsoft Visual Basic 2012 Using Procedures and Exception Handling CHAPTER SEVEN.
Introduction to Graphical User Interfaces. Objectives * Students should understand what a procedural program is. * Students should understand what an.
10-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf.
1 Κατανεμημένες Διαδικτυακές Εφαρμογές Πολυμέσων Γιάννης Πετράκης.
1/36 Database Programming with Visual Basic.Net and MS Access IKE Lab. Yunho Song Database Management and Analysis.
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 4 I Need a Tour Guide.
Needs for Accessing Database To make your web site more dynamic and maintainable, you can display information on your web pages that are retrieved from.
COMPUTER PROGRAMMING I Objective 7.03 Apply Built-in Math Class Functions.
1 Working with MS SQL Server Textbook Chapter 14.
C# Tutorial -1 ASP.NET Web Application with Visual Studio 2005.
Introduction to the Visual Studio.NET IDE (LAB 1 )
CIS 338: Using Queries in Access as a RecordSource Dr. Ralph D. Westfall May, 2011.
Effective Security in ASP.Net Applications Jatin Sharma: Summer 2005.
Windows Forms. Architecture Wrapper around WIN32API Part of the.NET Framework Code can be in C# or VB Toolbox has forms elements (buttons, etc.) Dragging.
Sample Application Multi Layered Architecture (n-tier): –Graphical User Interface (GUI): Forms, components, controls The Visual Designer in Visual Studio.
ASP.NET The Clock Project. The ASP.NET Clock Project The ASP.NET Clock Project is the topic of Chapter 23. By completing the clock project, you will learn.
1 CS 3870/CS 5870: Note 07 Lab 3 Lab 4 Test 1: Two Tables.
Christopher M. Pascucci.NET Programming: Databases & ADO.NET.
To access our web services, go to……. Click on Customer Login.
ADO.NET Objects – Data Providers Dr. Ron Eaglin. Requirements Visual Studio 2005 Microsoft SQL Server 2000 or 2005 –Adventure Works Database Installed.
Chapter Thirteen Working with Access Databases and LINQ Programming with Microsoft Visual Basic th Edition.
1 CS 3870/CS 5870: Note05 Prog3 Web Application with Database.
JDS – VB.NET Skill Session Fall 2004 Presented by YUHAO LIN.
Introduction to a Database Defining a database Database window in Access The six items in window: Tables, Queries Forms, Reports, Macros, Modules.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 25.1 Test-Driving the ATM Application 25.2.
Task #1 Create a relational database on computers in computer classroom 308, using MySQL server and any client. Create the same database, using MS Access.
HNDIT Rapid Application Development
Created by Alia Al-Abdulkarim 2008 Visual Basic Vs. Java.
Architecture Multi Layered Architecture (n-tier): Application: Model Controllers Database Access Graphical User Interface (GUI): Forms, components, controls.
1 Database Programming with ADO.NET Kashef Mughal.
1.NET Web Forms Applications: Main Form © 2002 by Jerry Post.
ADO.NET Objects Data Adapters Dr. Ron Eaglin. Agenda Builds on Information in Part I Should have working knowledge of creating a database connection Continuation.
Introduction to VB programming Dr. John P. Abraham UTPA Chapters 2 & 3.
CIS 338: VB.NET Printing Dr. Ralph D. Westfall May, 2011.
Computer Science Up Down Controls, Decisions and Random Numbers.
1 c6212 Advanced Database and Client Server MS SQL Server 2000 Stored Procedures and Parameters What ? Why ? How ?
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 11 Creating Web Applications and Writing Data to a Database.
Visual Basic Fundamental Concepts
ASP.NET Programming with C# and SQL Server First Edition
Stored Procedures Dr. Ralph D. Westfall May, 2011.
Lecture 6 VB.Net SQL Server.
GUI Programming using Windows Form
Introduction to VB programming
Visual Basic..
1.الدوال Function 2.الاجراءاتSub Procedure 3.وحده نمطيه Add Module
Accessing Databases with ADO.NET, Handling Exceptions, and Printing
These slides are for reference only. They are not "lecture notes"
Coding ADO.NET Objects: Connection, Command, DataReader
ASP.NET Relationships between tables
Chapter 10 Accessing Database Files
CIS 338: Images on Forms Dr. Ralph D. Westfall May, 2009.
GUI Programming in Visual Studio .NET
Presentation transcript:

Using ADO.Net to Build a Login System Dr. Ron Eaglin

Lecture This lecture will take you step by step through using SQL Server 2005 to create a Database Driven login system. –Requires SQL Server 2005 –Requires Visual Studio 2005

Requirements Login and password information will be stored in a database. Users will be presented a login screen that will allow them to; –Create a user account –Authenticate a login

Steps 1. Design Overall System Architecture 2. Design Database to Meet Requirements 3. Design Software System to Meet Needs 4. Build 5. Test 6. Deploy

Design (Visio)

Enterprise Application (in Visio)

Create Diagram and Document Design

System Architecture Design

Database Design Must be able to –(1) Keep names for users –(2) Keep login names for users –(3) Store passwords for users –(4) Check validity of password –(5) Create new users –(6) Verify new login names do not conflict

Database Design

Create New Table

Table Design Set as Primary Key So must be unique Null passwords are Not allowed

Table Design

Stored Procedures Check if login is valid Add new user to database

New Stored Procedure

Parameter Template (Ctrl-Shift M)

Add NewUser Procedure CREATE PROCEDURE nvarchar(200) AS BEGIN AS smallint = COUNT(*) FROM dbo.UserLogin WHERE LoginName

AddNewUser Procedure >= 1 BEGIN PRINT 'Login Name Already Exists in Database' RETURN END INSERT INTO dbo.UserLogin (LoginName, UserName, END GO

Stored Procedure Click Execute

Test Stored Procedure

isLoginValid Function

IsUserValid CREATE FUNCTION isUserValid ( -- Add the parameters for the function nvarchar(30) ) RETURNS SMALLINT AS BEGIN SMALLINT = COUNT(*) FROM dbo.UserLogin WHERE LoginName ANDUserPassword END GO

Test Function

UserValidResult Stored Procedure ALTER PROCEDURE int output AS BEGIN select END

Visual Studio 2005 Create Project

Windows Application We will create a Windows Application

Designer Page Form under construction Solution Explorer Properties of currently Selected object

VS Toolbox VS Toolbox contains all the objects That can be placed on the user form. In this example we will have a text box For the login name, the password, and A submit button.

Designing Form Place 2 labels (drag and drop From the toolbox, a text box And a masked text box on The form. Also drop a button. Line each of the items up.

Setting Properties Select Object Set Properties

Connecting to a Database

Connect to Database

Set Database Server Set Database within Server

Database Connection Connection info Will be in the Server explorer.

Code Window View Double click on Any object to Open a code Window.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim enteredUsername As String = Trim(TextBox1.Text) Dim enteredUserPassword As String = Trim(MaskedTextBox1.Text) Dim NumUsersFound As Integer Dim myConnection As New Data.SqlClient.SqlConnection myConnection.ConnectionString = "Data Source=WHITEWATER;Initial Catalog=CET4429;Integrated Security=True" Try myConnection.Open() Catch ex As Exception MsgBox("Could not open Connection", MsgBoxStyle.Information) Return End Try

Dim MyDataAdapter As New Data.SqlClient.SqlDataAdapter("UserValidResult", myConnection) MyDataAdapter.SelectCommand.CommandType = CommandType.StoredProcedure MyDataAdapter.SelectCommand.Parameters.Add(New _ SqlDbType.VarChar, 50)) MyDataAdapter.SelectCommand.Parameters.Add(New _ SqlDbType.VarChar, 30)) MyDataAdapter.SelectCommand.Parameters.Add(New _ SqlDbType.Int, 4))

= enteredUsername = enteredUserPassword = ParameterDirection.Output

Dim DS As New DataSet() 'Create a new DataSet to hold the records. MyDataAdapter.Fill(DS, "UserValidResult") 'Fill the DataSet with the rows returned NumUsersFound = If NumUsersFound = 0 Then MsgBox("No users found") Else MsgBox("Users found") End If myConnection.Close()

Results

Skill Summary User SQL Server 2005 Design and Create Tables Design and Create Application Create Stored Procedures and Functions Use Visual Studio Create a Windows Application Design a Form Use Database Object

Skill Summary Database Objects –Connection Object –Data Adapter –Parameter Objects –Data Set