我目前遇到了一个我无法解决的问题,我已经在互联网上进行了研究,但我发现的建议对我来说并不适用。
我正在尝试建立一个注册系统,只是为了娱乐而不是任何严肃的事情,但我很乐意知道我做错了什么,因为我可能有一天会使用这个。
编辑:我从@Gordon获得了解决方案以及许多其他可能非常有用的建议,我会考虑尝试所有建议。非常感谢=)
我的代码:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
mysqlconn = New MySqlConnection
mysqlconn.ConnectionString = "server=localhost;userid=root;password=password;database=Mysql"
Dim Reader As MySqlDataReader
If TxT_User.Text = "" Or TxT_Pass1.Text = "" Or TxT_Pass2.Text = "" Or TxT_Email.Text = "" Or TxT_SC.Text = "" Then
MsgBox("You need to fill out the required informations above", MsgBoxStyle.Critical)
Else
If TxT_Email.Text.Contains("@") Then
If TxT_Pass2.Text = TxT_Pass1.Text Then
Try
mysqlconn.Open()
Dim Query As String
Query = "INSERT INTO syntax.members (Username, Password, Email, Secret Answer) VALUES ('" & TxT_User.Text & "', '" & TxT_Pass1.Text & "', '" & TxT_Email.Text & "', '" & TxT_SC.Text & "')"
cmd = New MySqlCommand(Query, mysqlconn)
Reader = cmd.ExecuteReader
MsgBox("Account created!", MsgBoxStyle.Information)
mysqlconn.Close()
Catch ex As MySqlException
MsgBox(ex.Message, MsgBoxStyle.Information)
Finally
mysqlconn.Dispose()
End Try
Else
MsgBox("Your Password doesn't match the retyped version", MsgBoxStyle.Critical)
End If
Else
MsgBox("Your email is not valid, please type a valid email address", MsgBoxStyle.Critical)
End If
End If
End Sub
答案 0 :(得分:0)
一个明显的问题是“秘密答案”:
INSERT INTO syntax.members (Username, Password, Email, Secret Answer) . . .
不幸的是,我不知道你想要哪个:
INSERT INTO syntax.members (Username, Password, Email, `Secret Answer`) . . .
INSERT INTO syntax.members (Username, Password, Email, SecretAnswer) . . .
INSERT INTO syntax.members (Username, Password, Email, Secret, Answer) . . .
从价值清单来看,它是前两个之一。