Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports MySql.Data.MySqlClient
- Public Class Form3
- Public listbox3 As New ListBox
- Public splitread() As String
- Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- Dim conn As MySqlConnection
- conn = New MySqlConnection("server=db4free.net;Port=3306; user id=brandonioproduct; password=brandonio; database=brandonioproduct")
- Dim command As New MySqlCommand
- Dim sqlquery As String = "SELECT * FROM NewTable"
- Dim adapter As New MySqlDataAdapter
- Dim data As MySqlDataReader
- conn.Open()
- command.CommandText = sqlquery
- command.Connection = conn
- adapter.SelectCommand = command
- data = command.ExecuteReader
- While data.Read()
- ListBox1.Items.Add(data(3).ToString)
- listbox3.Items.Add(data(0).ToString)
- Dim writer As New System.IO.StreamWriter(My.Application.Info.DirectoryPath + "/" + data(3).ToString + data(0).ToString + ".txt", False)
- writer.Write(data(0).ToString + "=" + data(1).ToString + "=" + data(2).ToString + "=" + data(3).ToString + "=" + data(4).ToString + "=" + data(5).ToString)
- writer.Close()
- End While
- data.Close()
- conn.Close()
- End Sub
- Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
- listbox3.SelectedIndex = ListBox1.SelectedIndex
- Dim reader As New System.IO.StreamReader(My.Application.Info.DirectoryPath + "/" + ListBox1.SelectedItem.ToString + listbox3.SelectedItem.ToString + ".txt")
- splitread = reader.ReadToEnd.Split("=")
- reader.Close()
- lbl_name.Text = "Name : " + splitread(3).ToString
- lbl_password.Text = "Password : " + splitread(2).ToString
- lbl_username.Text = "Username : " + splitread(1).ToString
- lbl_favoritecolor.Text = "Favorite Color : " + splitread(4).ToString
- lbl_favoritefood.Text = "Favorite Food : " + splitread(5).ToString
- End Sub
- Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
- If CheckBox1.Checked = True Then
- 'Edit mode is enabled
- txt_favoritecolor.Visible = True
- txt_favoritefood.Visible = True
- txt_name.Visible = True
- txt_password.Visible = True
- txt_username.Visible = True
- txt_name.Text = splitread(3).tostring
- txt_password.Text = splitread(2).tostring
- txt_username.Text = splitread(1).tostring
- txt_favoritecolor.Text = splitread(4).tostring
- txt_favoritefood.Text = splitread(5).tostring
- lbl_name.Text = "Name : "
- lbl_password.Text = "Password : "
- lbl_username.Text = "Username : "
- lbl_favoritecolor.Text = "Favorite Color : "
- lbl_favoritefood.Text = "Favorite Food : "
- Button1.Visible = True
- Else
- 'Edit mode is disabled
- txt_favoritecolor.Visible = False
- txt_favoritefood.Visible = False
- txt_name.Visible = False
- txt_password.Visible = False
- txt_username.Visible = False
- lbl_name.Text = "Name : " + splitread(3).ToString
- lbl_password.Text = "Password : " + splitread(2).ToString
- lbl_username.Text = "Username : " + splitread(1).ToString
- lbl_favoritecolor.Text = "Favorite Color : " + splitread(4).ToString
- lbl_favoritefood.Text = "Favorite Food : " + splitread(5).ToString
- Button1.Visible = False
- End If
- End Sub
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- Dim conn As MySqlConnection
- conn = New MySqlConnection("server=db4free.net;Port=3306; user id=brandonioproduct; password=brandonio; database=brandonioproduct")
- Dim command As New MySqlCommand
- Dim sqlquery As String = "UPDATE NewTable SET Username='" & txt_username.Text & "', Password='" & txt_password.Text & "', Name='" & txt_name.Text & "', FavoriteColor='" & txt_favoritecolor.Text & "', FavoriteFood='" & txt_favoritefood.Text & "' WHERE ID='" & listbox3.SelectedItem & "';"
- Dim adapter As New MySqlDataAdapter
- Dim data As MySqlDataReader
- conn.Open()
- command.CommandText = sqlquery
- command.Connection = conn
- adapter.SelectCommand = command
- data = command.ExecuteReader
- data.Close()
- conn.Close()
- Me.Close()
- Dim form3 As New Form3
- form3.Show()
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement