d2005
Active member
i am trying to create a login, this may be very basic to most but any help would be appreciated,
dont worry my book is in the post.
is this gettin there, any further steps needed.
dont worry my book is in the post.
is this gettin there, any further steps needed.
VB.NET:
Imports System
Imports System.data
Imports System.Data.SqlClient
Imports System.Web.Security ' ||||| Required Class for Authentication
Imports System.Data.OleDb ' |||||| Access Database Required Import!
Imports System.Configuration ' |||||| Required for Web.Config appSettings |||||
' ||||| Connection String - XML coded in Web.Config
' ||||| Remember to set the Security Settings
Public Class login
Inherits System.Web.UI.Page
Dim oSQLConn As SqlConnection = New SqlConnection
Private dslogin As New DataSet
Protected WithEvents btn_login As System.Web.UI.WebControls.Button
Private dalogin As New SqlDataAdapter
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Protected WithEvents txt_user As System.Web.UI.WebControls.TextBox
Protected WithEvents txt_pass As System.Web.UI.WebControls.TextBox
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
Protected WithEvents Label2 As System.Web.UI.WebControls.Label
'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
End Sub
Private Sub connect()
oSQLConn.ConnectionString = "Data Source=(local);" & _
"Initial Catalog=TaT;" & _
"Integrated Security=SSPI"
oSQLConn.Open()
End Sub
Private Sub btn_login_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_login.Click
If Page.IsValid Then
' ||||| Connect to Database for User Validation |||||
dalogin.SelectCommand = New SqlCommand("SELECT comp_username, comp_password from tb_comp_login ", oSQLConn)
dalogin.Fill(dslogin)
If oSQLConn(txt_user.Text, txt_pass.Text) Then
FormsAuthentication.RedirectFromLoginPage(txt_user.Text, False) ' ||||| default.aspx Page!
Else
' ||||| Credentials are Invalid
'lblMessage.Text = "Invalid Login!"
End If
End If
End Sub
End Class