The document contains code for a Windows Forms application that manages player data using a SQL database, including functionalities for inserting, updating, deleting, and displaying player information. Additionally, it includes HTML templates for a restaurant and real estate website, outlining the structure for various pages such as home, menu, properties, and contact. Lastly, there is a Java applet that draws nested rectangles in different colors and displays the text 'Welcome' inside the innermost rectangle.
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 ratings0% found this document useful (0 votes)
4 views9 pages
VB
The document contains code for a Windows Forms application that manages player data using a SQL database, including functionalities for inserting, updating, deleting, and displaying player information. Additionally, it includes HTML templates for a restaurant and real estate website, outlining the structure for various pages such as home, menu, properties, and contact. Lastly, there is a Java applet that draws nested rectangles in different colors and displays the text 'Welcome' inside the innermost rectangle.
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
You are on page 1/ 9
Imports System.Data.
SqlClient
Public Class Form1
Dim connectionString As String = "Data Source=YourServer;Initial
Catalog=YourDatabase;Integrated Security=True"
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
RefreshData() End Sub
Private Sub RefreshData()
Dim query As String = "SELECT * FROM players ORDER BY country" Using connection As New SqlConnection(connectionString) Using command As New SqlCommand(query, connection) connection.Open() Dim adapter As New SqlDataAdapter(command) Dim dataTable As New DataTable() adapter.Fill(dataTable) DataGridView1.DataSource = dataTable End Using End Using End Sub
Private Sub ClearFields()
txtName.Clear() txtCountry.Clear() txtMatches.Clear() txtRuns.Clear() End Sub
Private Sub btnInsert_Click(sender As Object, e As EventArgs) Handles btnInsert.Click
Dim query As String = "INSERT INTO players (name, country, [no. of matches], [no of runs]) VALUES (@name, @country, @matches, @runs)" Using connection As New SqlConnection(connectionString) Using command As New SqlCommand(query, connection) connection.Open() command.Parameters.AddWithValue("@name", txtName.Text) command.Parameters.AddWithValue("@country", txtCountry.Text) command.Parameters.AddWithValue("@matches", Convert.ToInt32(txtMatches.Text)) command.Parameters.AddWithValue("@runs", Convert.ToInt32(txtRuns.Text)) command.ExecuteNonQuery() End Using End Using RefreshData() ClearFields() End Sub
Private Sub btnUpdate_Click(sender As Object, e As EventArgs) Handles btnUpdate.Click
Dim query As String = "UPDATE players SET name=@name, [no. of matches]=@matches, [no of runs]=@runs WHERE country=@country" Using connection As New SqlConnection(connectionString) Using command As New SqlCommand(query, connection) connection.Open() command.Parameters.AddWithValue("@name", txtName.Text) command.Parameters.AddWithValue("@matches", Convert.ToInt32(txtMatches.Text)) command.Parameters.AddWithValue("@runs", Convert.ToInt32(txtRuns.Text)) command.Parameters.AddWithValue("@country", txtCountry.Text) command.ExecuteNonQuery() End Using End Using RefreshData() ClearFields() End Sub
Private Sub btnDelete_Click(sender As Object, e As EventArgs) Handles btnDelete.Click
Dim query As String = "DELETE FROM players WHERE country=@country" Using connection As New SqlConnection(connectionString) Using command As New SqlCommand(query, connection) connection.Open() command.Parameters.AddWithValue("@country", txtCountry.Text) command.ExecuteNonQuery() End Using End Using RefreshData() ClearFields() End Sub
Private Sub btnDisplayByCountry_Click(sender As Object, e As EventArgs) Handles