0% found this document useful (0 votes)
17 views9 pages

NT Cast Long Form Management Tool

The document outlines a Visual Basic .NET application for managing student information, including functionalities for uploading images and documents, selecting caste and branch details, and inserting data into a MySQL database. It features event handlers for various UI components like ComboBoxes, TextBoxes, and Buttons to facilitate user interactions. The application also includes error handling and connection management for database operations.

Uploaded by

dasmitag147
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views9 pages

NT Cast Long Form Management Tool

The document outlines a Visual Basic .NET application for managing student information, including functionalities for uploading images and documents, selecting caste and branch details, and inserting data into a MySQL database. It features event handlers for various UI components like ComboBoxes, TextBoxes, and Buttons to facilitate user interactions. The application also includes error handling and connection management for database operations.

Uploaded by

dasmitag147
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Code:

Imports [Link]

Public Class Form2


Dim imgpath As String

Private Sub Button1_Click(sender As Object, e As EventArgs)

End Sub

Private Sub Form2_Load(sender As Object, e As EventArgs) Handles [Link]


[Link] = [Link]

' Hard-coded example: add cast names to the ComboBox


[Link]({"OBC", "NT-A", "NT-B", "ST", "SC", "OPEN"})

[Link] = [Link]

' Hard-coded example: add cast names to the ComboBox


[Link]({"Mechanical", "Electrical", "Civil", "Computer Science",
"IT", "Electronics"})

' hide Cast Document Upload label, textbox and button'


[Link] = False
[Link] = False
[Link] = False
End Sub

Private Sub TextBox4_TextChanged(sender As Object, e As EventArgs)

End Sub

Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles


[Link]

If [Link] <> -1 Then


Dim selectedCastName As String = [Link]()
' Display the selected cast name in the ComboBox
[Link] = selectedCastName

' Add your additional code here if needed


End If
End Sub

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles [Link]


Try
Dim ofd As New OpenFileDialog()

' Set the filter to allow only image files


[Link] = "Image Files (*.jpg;*.png;*.jpeg)|*.jpg;*.png;*.jpeg"

' Show the file dialog and check if the user selected a file
If [Link]() = [Link] Then
' Get the file path of the selected image and set it to the PictureBox
[Link] = [Link]
End If

' Dispose the file dialog object


[Link]()
Catch ex As Exception
' Display an error message if an exception occurs
MsgBox([Link])
End Try
End Sub

Private Sub Label9_Click(sender As Object, e As EventArgs) Handles [Link]

End Sub

Private Sub PictureBox1_Click(sender As Object, e As EventArgs) Handles [Link]

End Sub

Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles [Link]


[Link] = "PDF Files|*.pdf"

If [Link]() = [Link] Then


' Get the selected PDF file path
Dim pdfFilePath As String = [Link]

' Display the file path in a TextBox


[Link] = pdfFilePath
End If
End Sub

Private Sub TextBox7_TextChanged(sender As Object, e As EventArgs) Handles


[Link]

End Sub

Private Sub ComboBox2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles


[Link]
If [Link] <> -1 Then
Dim selectedCastName As String = [Link]()
' Display the selected cast name in the ComboBox
[Link] = selectedCastName

' Add your additional code here if needed


End If
End Sub

Private Sub RadioButton1_CheckedChanged(sender As Object, e As EventArgs) Handles


[Link]
If [Link] Then
' Show the label, textbox, and button
[Link] = True
[Link] = True
[Link] = True
End If
End Sub

Private Sub CheckConnection()


Try
[Link]()

If [Link] = [Link] Then


'' [Link]("Connected to the database.", "Success",
[Link], [Link])
Else
[Link]("Failed to connect to the database.", "Error",
[Link], [Link])
End If
Catch ex As Exception
[Link]("Error: " & [Link], "Error", [Link],
[Link])
Finally
' Always close the connection to release resources
If [Link] = [Link] Then
[Link]()
End If
End Try
End Sub

Private Sub RadioButton2_CheckedChanged(sender As Object, e As EventArgs) Handles


[Link]
If [Link] Then
' Hide the label, textbox, and button
[Link] = False
[Link] = False
[Link] = False
End If
End Sub
Dim connectionString As String = "server=localhost;user
id=root;password=1234;database=student_management_system"
Dim conn As New MySqlConnection(connectionString)

Private Sub button3_Click(sender As Object, e As EventArgs) Handles [Link]


Try
Dim arrimage() As Byte

CheckConnection()
Dim msstream As New [Link]()
[Link](msstream, [Link])
arrimage = [Link]()
[Link]()

[Link]()

Dim command As New MySqlCommand("INSERT INTO student_info (photo, name,


address, contact_no, adhar_no, caste, caste_certificate, document, branch_name,
college_name, admission_date, fees, year) VALUES (@photo, @name, @address,
@contact_no, @adhar_no, @caste, @caste_certificate, @document, @branch_name,
@college_name, @admission_date, @fees, @year)", conn)

[Link]("@photo", arrimage)
[Link]("@name", [Link])
[Link]("@address", [Link])
[Link]("@contact_no", [Link])
[Link]("@adhar_no", [Link])
[Link]("@caste", [Link])
If [Link] Then
[Link]("@caste_certificate", "Yes")
ElseIf [Link] Then
[Link]("@caste_certificate", "No")
End If

' Add the remaining parameters (adjust the names accordingly)


[Link]("@document", [Link])
[Link]("@branch_name", [Link])
[Link]("@college_name", "bhausaheb vartak
polytechnic")
[Link]("@admission_date",
[Link]("yyyy-MM-dd"))
[Link]("@fees", Convert.ToInt32([Link]))
[Link]("@year", [Link])

' Execute the command to insert data into the database


Dim x As Integer = [Link]()

If x > 0 Then
[Link]("Data Inserted")
[Link]()

Dim Form1 As New Form1()


[Link]()
Else
[Link]("Data Not Inserted")
End If

Catch ex As Exception
[Link]("Error: " & [Link])
Finally
[Link]()
End Try
End Sub

Private Sub Label4_Click(sender As Object, e As EventArgs) Handles [Link]

End Sub

Private Sub txtPassword_TextChanged(sender As Object, e As EventArgs) Handles


[Link]

End Sub

Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles


[Link]

End Sub

Private Sub TextBox2_TextChanged(sender As Object, e As EventArgs) Handles


[Link]

End Sub

Private Sub TextBox3_TextChanged(sender As Object, e As EventArgs) Handles


[Link]

End Sub

Private Sub TextBox4_TextChanged_1(sender As Object, e As EventArgs)

End Sub

Private Sub DateTimePicker1_ValueChanged(sender As Object, e As EventArgs) Handles


[Link]

End Sub

Private Sub Label2_Click(sender As Object, e As EventArgs)

End Sub

Private Sub PictureBox2_Click(sender As Object, e As EventArgs) Handles [Link]


[Link]()
Dim Form1 As New Form1()
[Link]()
End Sub

Private Sub Label11_Click(sender As Object, e As EventArgs) Handles [Link]

End Sub

Private Sub PictureBox3_Click(sender As Object, e As EventArgs) Handles [Link]

End Sub

Private Sub Label1_Click(sender As Object, e As EventArgs) Handles [Link]

End Sub

Private Sub Panel3_Paint(sender As Object, e As PaintEventArgs) Handles [Link]

End Sub
End Class

Output:
[Link] page
[Link] Page

3. Add student
4. Student List

[Link] Detail
[Link]

7. Delete

Common questions

Powered by AI

The application employs a structured try-catch-finally block for error handling during database operations. If any exception arises while performing database tasks, it catches the exception and displays the error message to the user through a MessageBox. The finally block ensures that the database connection is closed in order to release resources, regardless of whether an exception occurred .

The program utilizes RadioButton controls to dynamically show or hide UI elements. When RadioButton1 is checked, it makes Label16, TextBox7, and Button1 visible. Conversely, if RadioButton2 is checked, it hides these elements. This approach allows for a tailored user interface based on the selected options .

The application ensures connection efficiency by opening the SQL connection only when necessary and checking its state before performing operations. It uses a finally block to guarantee that the connection is closed after operations are complete, preventing resource leaks and maximizing efficiency. Despite this, additional pooling techniques could enhance performance further by reusing connections .

The application uses an OpenFileDialog to allow users to select image files with the extension jpg, png, or jpeg. Once a file is selected, the file path is retrieved and assigned to the PictureBox's ImageLocation property to display the image. The OpenFileDialog object is disposed of after use to free up resources .

After attempting to process and insert data into the database, the application evaluates the number of affected rows. If greater than zero, it displays a success message using MessageBox. Otherwise, it informs the user of the failure to insert data, offering immediate feedback on the operation's outcome .

Storing images as byte arrays (BLOB) in a database allows for efficient storage and retrieval of image data. In the application, images are first saved into a MemoryStream and then converted into a byte array before being inserted into the database via a MySqlCommand. This method ensures that the image data is compactly stored and easily retrievable .

Data is inserted into the student_info table using a parameterized query via MySqlCommand. Each input control value in the form is collected and passed as parameters to prevent SQL injection attacks. The application checks the number of affected rows to confirm data insertion success. Although this approach is secure, improvements could include input validation before insertion and leveraging transaction management to ensure data integrity during bulk operations .

The MemoryStream class is crucial for efficiently manipulating image data in memory without temporary files. In this application, images are saved to a MemoryStream and converted into byte arrays for database storage. This method maintains high performance and reduces disk I/O overhead, facilitating seamless integration and processing of images within the application .

The admission date is obtained from a DateTimePicker control, which provides flexibility and precision in date selection. The date is then formatted to 'yyyy-MM-dd' before being stored in the database, ensuring consistency and compatibility with SQL date data types .

ComboBox controls are used to present predefined lists for selecting caste and branch options. They are initialized with specific items upon form load. Programmatically, item selection is managed by setting the ComboBox text to the selected item string upon a change in selection, allowing for straightforward access to the chosen value .

You might also like