Download presentation
Presentation is loading. Please wait.
Published byBryce Chambers Modified over 6 years ago
1
How to Create Login Form using vb.net and SqlServer Database
2
Imports System.Data.SqlClient library has a variety of classes and methods The classes we used to build log in form will be demonstrated which are : - Sqlconnection - Sqlcommand - sqldatareader
3
Sqlconnection Class Represents an open connection to a SQL Server database. This class cannot be inherited. Objects Properties Class name Sqlconnection Connectionstring() open() Con
4
Open () Connectionstring()
Gets or sets the string used to open a SQL Server database. Open () Opens a database connection with the property settings specified by the Connectionstring
5
Sqlcommand Class Represents a Transact-SQL statement or stored procedure to execute against a SQL Server database. This class cannot be inherited. Objects Properties Class name sqlcommand Connection() Excutereader() Commandtext() Cmd
6
Commandtext() CONNECTION()
Gets or sets the Transact-SQL statement, table name or stored procedure to execute at the data source. CONNECTION() Gets or sets the SqlConnection used by this instance of the SqlCommand
7
ExecuteReader() Sqlcommand Method that Sends the CommandText to the Connection and builds a SqlDataReader. Retrieving data using a DataReader involves creating an instance of the Command object and then creating a DataReader by calling Command.ExecuteReader to retrieve rows from a data source.
8
Sqldatareader Class Provides a way of reading a forward-only stream of rows from a SQL Server database. This class cannot be inherited. Objects Properties Class name Sqldatareader hasrows() rd
9
Hasrows() Gets a value that indicate whether that sqldatareader contains one or more rows .
10
Imports System.Data.SqlClient
Dim con As New SqlConnection Dim cmd As New SqlCommand Dim rd As SqlDataReader con.ConnectionString = "Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\FitNation.mdf;Integrated Security=True;User Instance=True" cmd.Connection = con con.Open() cmd.CommandText = "select Username,Password from Trianer where Username = '" & TextBox1.Text & "' and Password= '" & TextBox2.Text & "'" rd = cmd.ExecuteReader If rd.HasRows Then Form4.Show() Else MsgBox("invalid username,password") End If
11
THE END
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.