Vb.net Project With Coding -

CREATE DATABASE StudentDB; GO USE StudentDB; GO

Happy coding! 🚀

MessageBox.Show("Student added successfully!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information) ClearFields() LoadAllStudents() End If End Sub Vb.net Project With Coding

' Clear all input fields Private Sub btnClear_Click(sender As Object, e As EventArgs) Handles btnClear.Click ClearFields() End Sub

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()) CREATE DATABASE StudentDB; GO USE StudentDB; GO Happy

Imports System.Data.SqlClient Module DatabaseHelper ' Change the connection string based on your SQL Server instance Public connectionString As String = "Data Source=(LocalDB)\MSSQLLocalDB;Initial Catalog=StudentDB;Integrated Security=True"

Using conn As SqlConnection = GetConnection() Using cmd As New SqlCommand(query, conn) cmd.Parameters.AddWithValue("@StudentID", Convert.ToInt32(txtStudentID.Text)) CREATE DATABASE StudentDB

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

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

' 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 String.IsNullOrWhiteSpace(txtCourse.Text) Then MessageBox.Show("Course is required.", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Warning) Return False End If

Política de cookies

Utilizamos cookies propias y de terceros, para realizar el análisis de la navegación de los usuarios. Si continúas navegando, consideramos que aceptas su uso. Puedes cambiar la configuración u obtener más información aquí.

ACEPTAR
Aviso de cookies