Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 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