Vb.net Project With - Coding
CREATE DATABASE StudentDB; GO USE StudentDB; GO
' Update Student Private Sub btnUpdate_Click(sender As Object, e As EventArgs) Handles btnUpdate.Click If String.IsNullOrWhiteSpace(txtStudentID.Text) Then MessageBox.Show("Please select a student to update.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning) Return End If Vb.net Project With Coding
dgvStudents.DataSource = dataTable
If rowsAffected > 0 Then MessageBox.Show("Student updated successfully!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information) ClearFields() LoadAllStudents() Else MessageBox.Show("Student not found.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error) End If End Using End Using End If End Sub CREATE DATABASE StudentDB; GO USE StudentDB; 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 : CREATE DATABASE StudentDB
conn.Open() cmd.ExecuteNonQuery() conn.Close() End Using End Using
If dataTable.Rows.Count = 0 Then MessageBox.Show("No students found.", "Search Result", MessageBoxButtons.OK, MessageBoxIcon.Information) End If End Sub