0% found this document useful (0 votes)
31 views

Default2: "Prac5" "Select Account - Name, Current - Balance From Customer Where Password "

This document contains code for a web form that allows a user to log in with a password and retrieve their account name and current balance from a database. When the user clicks the login button, the code opens a database connection, executes a SQL query to retrieve the user's data where the password matches the input, and displays the results on the form. If login fails, it displays an error message.

Uploaded by

Sidzwozz Dupeti
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views

Default2: "Prac5" "Select Account - Name, Current - Balance From Customer Where Password "

This document contains code for a web form that allows a user to log in with a password and retrieve their account name and current balance from a database. When the user clicks the login button, the code opens a database connection, executes a SQL query to retrieve the user's data where the password matches the input, and displays the results on the form. If login fails, it displays an error message.

Uploaded by

Sidzwozz Dupeti
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Prac5:

Imports System.Web.Configuration
Imports System.Data.Sql
Imports System.Data.SqlClient
Partial Class Default2
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles


Me.Load
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Button1.Click
Try
Dim conStr As String =
WebConfigurationManager.ConnectionStrings("Prac5").ConnectionString
Dim myconn As New SqlConnection(conStr)
Dim mycomm As New SqlCommand("Select Account_Name, Current_Balance from
Customer where Password =" & TextBox2.Text, myconn)
Dim myReader As SqlDataReader
myconn.Open()
myReader = mycomm.ExecuteReader
myReader.Read()
Label3.Text = myReader("Account_Name")
Label4.Text = myReader("Current_Balance")
myReader.Close()
myconn.Close()
Catch ex As Exception
Label3.Text = "Wrong Password"
Label4.Text = ""
End Try
End Sub
Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Button2.Click
Label3.Text = ""
Label4.Text = ""
End Sub
End Class

You might also like