0% found this document useful (0 votes)
221 views2 pages

VB.NET Profile Database Manager

This code defines a class that allows for loading, inserting, updating, deleting, and searching data from a SQL database table into a data grid view. It opens a SQL connection, loads initial data into the grid, and handles buttons to insert, update, delete, and search records by executing parameterized SQL queries and reloading the data grid.

Uploaded by

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

VB.NET Profile Database Manager

This code defines a class that allows for loading, inserting, updating, deleting, and searching data from a SQL database table into a data grid view. It opens a SQL connection, loads initial data into the grid, and handles buttons to insert, update, delete, and search records by executing parameterized SQL queries and reloading the data grid.

Uploaded by

Trust Kagura
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
  • Initialization and Setup
  • Button Click Events
  • Form Load Event

Imports [Link].

SqlClient

Public Class Form1


Dim query As String = "server=(localdb)\Projects;database=dbprofile"
Dim con As New SqlConnection(query)

Sub loaddata()
Dim query As String = "select * from profile"
Dim adpt As New [Link](query, con)
Dim ds As New DataSet()
[Link](ds, "Emp")
[Link] = [Link](0)
[Link]()
[Link]()
[Link]()
[Link]()
[Link]()
[Link]()
End Sub

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


loaddata()
End Sub

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


[Link]
Dim cmd As SqlCommand
[Link]()
Try
cmd = [Link]
[Link] = "Insert into
profile(id,name,email,website)values(@id,@name,@email,@website);"
[Link]("@id", [Link])
[Link]("@name", [Link])
[Link]("@email", [Link])
[Link]("@website", [Link])
[Link]()
loaddata()
Catch ex As Exception
End Try
End Sub

Private Sub DataGridView1_CellContentClick_1(sender As Object, e As


DataGridViewCellEventArgs) Handles [Link]
Dim row As DataGridViewRow = [Link]
Try
[Link] = [Link](0).[Link]()
[Link] = [Link](1).[Link]()
[Link] = [Link](2).[Link]()
[Link] = [Link](3).[Link]()
Catch ex As Exception
End Try
End Sub

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


[Link]
Dim cmd As SqlCommand
[Link]()
Try
cmd = [Link]()
[Link] = "Update profile set
id=@id,name=@name,email=@email,website=@website"
[Link]("@id", [Link])
[Link]("@name", [Link])
[Link]("@email", [Link])
[Link]("@website", [Link])
[Link]()
loaddata()
Catch ex As Exception
End Try
End Sub

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


[Link]
Dim cmd As SqlCommand
[Link]()
Try
cmd = [Link]()
[Link] = "Delete from profile where id=@id;"
[Link]("@id", [Link])
[Link]()
loaddata()
Catch ex As Exception
End Try
End Sub

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


[Link]
Dim adapter As SqlDataAdapter
Dim ds As New DataSet
Try
[Link]()
adapter = New SqlDataAdapter("Select * from profile where name like '%"
& [Link] & "%'", con)
[Link](ds)
[Link] = [Link](0)
[Link]()
[Link]()
[Link]()
[Link]()
[Link]()
Catch ex As Exception
End Try
End Sub

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


[Link]
loaddata()
End Sub

End Class

Imports System.Data.SqlClient
Public Class Form1
    Dim query As String = "server=(localdb)Projects;database=dbprofile"
Try
            cmd = con.CreateCommand()
            cmd.CommandText = "Update profile set 
id=@id,name=@name,email=

You might also like