Feb 3, 2015 06:35 PM
(This post was last modified: Feb 4, 2015 09:26 AM by SIM-297877.)
I am able to read, insert, and delete data from my MySQL database but i need to be able to update the data too...
Here is how i insert data (showing the coloums)
I load the data into the panel (add and Edit panel) via;
I really need help trying to make it so i can update the data using the same information panel... (ie. where i get the info for inserting into the db)
Still really need some help with this one... Everything i try errors or just plain dont work.
Here is how i insert data (showing the coloums)
PHP Code
<?php
Dim result As DialogResult = MessageBox.Show("Have you made sure to see any changes have happend to the DB?", "Check the Database!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning)
If result = DialogResult.Yes Then
con.ConnectionString = ("server=" & MySQLServer & ";user id=" & MySQLUsername & ";password=" & MySQLPassword & ";database=" & MySQLDatabase)
Try
con.Open()
Dim sb As New System.Text.StringBuilder
For Each item In CheckedListBox1.CheckedItems
sb.Append(item)
sb.Append(" ")
Next
With cmd
.Connection = con
.CommandText = "INSERT INTO `" & MySQLTable & "` (`id`, `rank`, `username`, `games`, `status`, `enlistdate`, `recruiter`, `timedone`, `notes`, `ip`) " & _
"VALUES (NULL, '" & ComboBox1.Text & "', '" & TextBox1.Text & "', '" & sb.ToString() & "', '" & ComboBox2.Text & "', '" & MonthCalendar1.SelectionRange.Start & "', '" & TextBox2.Text & "', '" & NumericUpDown1.Value.ToString & "', '" & TextBox3.Text & "', '" & MyClientIP & "');"
result = cmd.ExecuteNonQuery
If result = 0 Then
MsgBox("Data has been Inserted!")
Refresh()
Else
MsgBox("Successfully saved!")
Refresh()
End If
End With
Catch ex As Exception
MessageBox.Show("Database Error: " & ex.Message)
End Try
con.Close()
ElseIf result = DialogResult.No Then
MessageBox.Show("Try again after you check for DB updates.")
Else
End If
I load the data into the panel (add and Edit panel) via;
PHP Code
<?php
Private Sub DataGridView1_CellMouseClick(sender As Object, e As DataGridViewCellMouseEventArgs) Handles DataGridView1.CellMouseClick
Try
TmpID = DataGridView1.CurrentRow.Cells(0).Value
ComboBox1.Text = DataGridView1.CurrentRow.Cells(1).Value
TextBox1.Text = DataGridView1.CurrentRow.Cells(2).Value
Dim TmpStrng As String() = DataGridView1.CurrentRow.Cells(3).Value.ToString.Split(New Char() {" "c})
Dim TmpGames As String
For Each TmpGames In TmpStrng
Dim I As Integer
For I = 0 To CheckedListBox1.Items.Count - 1
If CheckedListBox1.Items(I).IndexOf(TmpGames) <> -1 Then
CheckedListBox1.SetItemChecked(I, True)
End If
Next
Next
ComboBox2.Text = DataGridView1.CurrentRow.Cells(4).Value
MonthCalendar1.SelectionRange.Start = DataGridView1.CurrentRow.Cells(5).Value
TextBox2.Text = DataGridView1.CurrentRow.Cells(6).Value
NumericUpDown1.Value = Convert.ToInt32(DataGridView1.CurrentRow.Cells(7).Value)
TextBox3.Text = DataGridView1.CurrentRow.Cells(8).Value
Catch ex As Exception
TmpID = 0
ComboBox1.Text = "Recruit.gif"
TextBox1.Text = ""
ComboBox2.Text = ""
TextBox2.Text = ""
NumericUpDown1.Value = 1
TextBox3.Text = ""
End Try
End Sub
I really need help trying to make it so i can update the data using the same information panel... (ie. where i get the info for inserting into the db)
Still really need some help with this one... Everything i try errors or just plain dont work.
Go Programmer, Adept in CAD, Adept in 3D Printing, Need something made? PM me.


