Update mySql table according to different conditions

后端 未结 1 1775
星月不相逢
星月不相逢 2021-01-27 03:11

I got this code from this site and now I need to add some change.

I know I acted fool here.

I searched many and got stuck in here. I wanted to add 1 to the sql

相关标签:
1条回答
  • 2021-01-27 04:02

    You must do this, to get it running But it must be clear this is vulnurable to sql injection

    So you must check TextBox4.Text for valid content.

    Dim sql As String = "UPDATE attendance.student SET `" & TextBox4.Text & "` = `" & TextBox4.Text & "` +1 WHERE S_name = @name;” 
    Dim conn As MysqlConnection 
    Try conn = New MySqlConnection(ConnectionString)
      Dim cmd As New MySqlCommand(sql, conn)
      cmd.Parameters.Add(“@name”, MySqlDbType.VarString, 50).Value = TextBox1.Text
    
    0 讨论(0)
提交回复
热议问题