gpt4 book ai didi

mysql - 在 if 语句 vb.net 中跳过更新查询

转载 作者:行者123 更新时间:2023-11-30 21:56:36 25 4
gpt4 key购买 nike

我现在不明白为什么在 if 语句中跳过该方法有人可以帮我解决这个问题吗?

这里是更新sql查询

    Public Sub Edituser()
conn()
dbconn.Open()
sql = "UPDATE player SET First Name=@1 Last Name=@2, Gender=@3, Date of Birth=@4, Civil Status=@5, Nationality=@6, Address=@7, Status=@8 WHERE ID = " + TextBox8.Text + ""
Try
dbcomm = New MySqlCommand(sql, dbconn)
dbcomm.Parameters.Add(New MySqlParameter("@1", TextBox1.Text))
dbcomm.Parameters.Add(New MySqlParameter("@2", TextBox2.Text))
dbcomm.Parameters.Add(New MySqlParameter("@3", TextBox9.Text))
dbcomm.Parameters.Add(New MySqlParameter("@4", TextBox3.Text))
dbcomm.Parameters.Add(New MySqlParameter("@5", TextBox4.Text))
dbcomm.Parameters.Add(New MySqlParameter("@6", TextBox5.Text))
dbcomm.Parameters.Add(New MySqlParameter("@7", TextBox6.Text))
dbcomm.Parameters.Add(New MySqlParameter("@8", TextBox7.Text))
dbread = dbcomm.ExecuteReader()
dbread.Close()
MsgBox("Successfully updated!")
Catch ex As Exception
Finally
dbconn.Close()
End Try
End Sub

这是if语句

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = "" Or TextBox4.Text = "" Or TextBox5.Text = "" Or TextBox6.Text = "" Or TextBox7.Text = "" Or TextBox9.Text = "" Then
MsgBox("Please complete all the fields")
Else
Dim result As Integer = MessageBox.Show("Are you sure you want to Edit the information?", "Update", MessageBoxButtons.OKCancel, MessageBoxIcon.Question)
If result = DialogResult.OK Then


Edituser()

MsgBox(" Player information Updated!")
Me.Close()
Player.Show()
End If

End If
End Sub

提前致谢。

最佳答案

您的 UPDATE 语句在语法上是错误的,因为它缺少 , 和正确的列名引号,如下所示

sql = "UPDATE player SET `First Name`=@1, `Last Name`=@2, Gender=@3, `Date of Birth`=@4,

关于mysql - 在 if 语句 vb.net 中跳过更新查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44947613/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com