Vb.net Project With Coding < 2024 >

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

If numAge.Value < 1 OrElse numAge.Value > 100 Then MessageBox.Show("Age must be between 1 and 100.", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Warning) Return False End If

' 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 Vb.net Project With Coding

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

MessageBox.Show("Student deleted successfully.", "Deleted", MessageBoxButtons.OK, MessageBoxIcon.Information) ClearFields() LoadAllStudents() End If End Sub Using conn As SqlConnection = GetConnection() Using cmd

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

Dim query As String = "SELECT StudentID, Name, Age, Course FROM Students WHERE Name LIKE @Search + '%'" Dim dataTable As New DataTable() txtCourse.Text.Trim()) If numAge.Value &lt

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())

© 101hacker | Design by Mukund edited by John
Powered by Blogger