Meetings & Events
Fifteenth Floor

Garden Terrace

Contact Us

Vb.net Project With Coding Apr 2026

' 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

If ValidateInputs() Then Dim query As String = "UPDATE Students SET Name=@Name, Age=@Age, Course=@Course WHERE StudentID=@StudentID"

Using conn As SqlConnection = GetConnection() Using cmd As New SqlCommand(query, conn) cmd.Parameters.AddWithValue("@Name", txtName.Text.Trim()) cmd.Parameters.AddWithValue("@Age", numAge.Value) cmd.Parameters.AddWithValue("@Course", txtCourse.Text.Trim())

conn.Open() cmd.ExecuteNonQuery() conn.Close() End Using End Using Vb.net Project With Coding

Using conn As SqlConnection = GetConnection() Using adapter As New SqlDataAdapter(query, conn) adapter.Fill(dataTable) End Using End Using

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

| Control Type | Name | Text / Purpose | |--------------|------|----------------| | Label | - | "Student Management System" (Font: bold) | | Label | - | "Student ID" | | TextBox | txtStudentID | (ReadOnly for auto-generated ID) | | Label | - | "Name" | | TextBox | txtName | | | Label | - | "Age" | | NumericUpDown | numAge | Minimum=1, Maximum=100 | | Label | - | "Course" | | TextBox | txtCourse | | | Button | btnAdd | Add Student | | Button | btnUpdate | Update | | Button | btnDelete | Delete | | Button | btnClear | Clear Fields | | TextBox | txtSearch | Search box | | Button | btnSearch | Search | | DataGridView | dgvStudents | (Dock: Bottom, Anchor: Top,Bottom,Left,Right) | Create a new module DatabaseHelper.vb : Name NVARCHAR(100) NOT NULL

' Search by Name Private Sub btnSearch_Click(sender As Object, e As EventArgs) Handles btnSearch.Click Dim searchValue As String = txtSearch.Text.Trim()

' 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)"

CREATE DATABASE StudentDB; GO USE StudentDB; GO Age INT NOT NULL

If result = DialogResult.Yes Then Dim query As String = "DELETE FROM Students WHERE StudentID=@StudentID"

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

MessageBox.Show("Student deleted successfully.", "Deleted", MessageBoxButtons.OK, MessageBoxIcon.Information) ClearFields() LoadAllStudents() End If End Sub

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