Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

Need help with updating MySQL

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)
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.
PHP Code

<?php 
strQuery 
= "UPDATE users SET value1 = '" & value1variable & "', value2 = '" & value2variable & WHERE id = '" & usernameid & "' '" 
and then execute the nonquerry.

where ID is so it updates that user's colum.

i hope you get the idea mate.
example http://www.w3schools.com/sql/sql_update.asp


Possibly Related Threads...
Thread / Author Replies Views Last Post
[.NET] by GruntStylDec 6, 2016 04:45 AM 1 178 Dec 6, 2016 04:45 AM
Last Post: Rhez
[C#] by siimon00Sep 28, 2016 09:58 PM 5 202 Sep 28, 2016 09:58 PM
Last Post: some_dude13
[.NET] by Netflix and WeedApr 17, 2016 03:04 PM 4 149 Apr 17, 2016 03:04 PM
Last Post: Netflix and Weed