jacob Denis jacob Denis - 1 year ago 53
SQL Question

My code is not working. Am I doing it right?

what i wanted to achieve is, i will choose what column should i update, this is why i am experimenting on my code but did not work and now i think i need some help.

Dim btnup="col1"
Dim btnval="1"
Dim mysqlconn As New MySqlConnection
Dim conStr As String
conStr = "Server=localhost; user id=root; password=; database=dnc_floor"
mysqlconn = New MySqlConnection(conStr)

Dim update As String
Dim cmd As MySqlCommand
update = "Update floor set ='" & btnup & "'=btnval where ID='" & Day & "'"
cmd = New MySqlCommand(update, mysqlconn)
Dim check As String = cmd.ExecuteNonQuery()
Catch ex As MySqlException
MessageBox.Show("Check your connection with your database")
End Try

Answer Source

The update string is probably wrong. Maybe u think of that:

  update = "Update floor set " & btnup & " ='" & btnval & "'  where ID= '" & Day & "'"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download