Vb.net Project With Coding [BEST]

Private Sub ClearFields() txtStudentID.Clear() txtName.Clear() numAge.Value = 18 txtCourse.Clear() txtName.Focus() End Sub

Dim result As DialogResult = MessageBox.Show("Are you sure you want to delete this student?", "Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question)

' Add Student Private Sub btnAdd_Click(sender As Object, e As EventArgs) Handles btnAdd.Click If ValidateInputs() Then Dim query As String = "INSERT INTO Students (Name, Age, Course) VALUES (@Name, @Age, @Course)" Vb.net Project With Coding

If dataTable.Rows.Count = 0 Then MessageBox.Show("No students found.", "Search Result", MessageBoxButtons.OK, MessageBoxIcon.Information) End If End Sub

' Delete Student Private Sub btnDelete_Click(sender As Object, e As EventArgs) Handles btnDelete.Click If String.IsNullOrWhiteSpace(txtStudentID.Text) Then MessageBox.Show("Please select a student to delete.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning) Return End If Private Sub ClearFields() txtStudentID

Public Function GetConnection() As SqlConnection Return New SqlConnection(connectionString) End Function End Module Imports System.Data.SqlClient Public Class Form1 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load LoadAllStudents() End Sub

If String.IsNullOrEmpty(searchValue) Then LoadAllStudents() Return End If Course) VALUES (@Name

CREATE TABLE Students ( StudentID INT PRIMARY KEY IDENTITY(1,1), Name NVARCHAR(100) NOT NULL, Age INT NOT NULL, Course NVARCHAR(100) NOT NULL ); GO

conn.Open() cmd.ExecuteNonQuery() conn.Close() End Using End Using