-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathViewProfile.vb
38 lines (32 loc) · 1.48 KB
/
ViewProfile.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
Imports System.Data.SqlClient
Public Class ViewProfile
Private ReadOnly _studentId As String
Public Sub New(studentID As String)
' This call is required by the designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
_studentId = studentID
End Sub
Private Sub ViewProfile_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim connectionString As String = "Data Source=DESKTOP-JI8QG4T\SQLSERVER2022;Initial Catalog=collegestudent;Integrated Security=True"
Dim query As String = "SELECT * FROM studentreg WHERE StudentId = @stdId"
Dim dataTable As New DataTable()
Using connection As New SqlConnection(connectionString)
Dim dataAdapter As New SqlDataAdapter(query, connection)
dataAdapter.SelectCommand.Parameters.AddWithValue("@stdID", _studentId)
connection.Open()
dataAdapter.Fill(dataTable)
End Using
With ProfileDataGrid
.DataSource = dataTable
.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells
End With
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Me.Close()
End Sub
Private Sub UpdateButton_Click(sender As Object, e As EventArgs) Handles UpdateButton.Click
Dim updateForm As New UpdateProfile(_studentId)
updateForm.Show()
End Sub
End Class