我认为缺少某些东西或者我使用了错误的语法。你能帮我跟踪一下我的错误吗?
Private Sub AddScholarbtn_Click()
If txtSchoolID = "" Then
MsgBox ("Input ID")
ElseIf txtSSName = "" Then
MsgBox ("Input Surname")
ElseIf txtSGName = "" Then
MsgBox ("Input Given Name")
ElseIf txtSMName = "" Then
MsgBox ("Input Middle Name")
ElseIf txtAddress = "" Then
MsgBox "Null"
ElseIf txtBirthPlace = "" Then
MsgBox "Null"
ElseIf ComboMonth = "" Then
MsgBox "Select Month"
ElseIf ComboDay = "" Then
MsgBox ("Select Day")
ElseIf ComboYear = "" Then
MsgBox "Select Year"
ElseIf comboGender = "" Then
MsgBox "Select Gender"
ElseIf ComboCivilStatus = "" Then
MsgBox "Select Status"
ElseIf txtAge = "" Then
MsgBox ("Input Age")
ElseIf txtContactInfo = "" Then
MsgBox "Null"
ElseIf txtEmail = "" Then
MsgBox "Null"
ElseIf txtGuardian = "" Then
MsgBox "Null"
ElseIf txtGContact = "" Then
MsgBox ("Null")
ElseIf txtYOA = "" Then
MsgBox "Null"
ElseIf comboProgram = "" Then
MsgBox "Null"
Else
Dim ans
ans = MsgBox("Are you sure you want to Save this Scholar?", vbYesNo, "Save")
If ans = vbYes Then
''''''''''''In this line where the yellow color/error occurs
DBConnect.Execute "INSERT INTO tblScholarProfile VALUES(" + txtSchoolID + ",'" + txtSSName + "','" + txtSGName + "','" + txtSMName + "' ," & _
" '" + txtAddress + "','" + txtBirthPlace + "','" + ComboMonth + "'," + ComboDay + "," + ComboYear + "," & _
" '" + comboGender + "','" + ComboCivilStatus + "'," + txtAge + "," + txtContactInfo + ",'" + txtEmail + "','" + txtGuardian + "'," + txtGContact + "," + txtYOA + ",'" + comboProgram + "')"
我真的不知道我错了。
MsgBox "You have successfully save a new Scholar"
Else
MsgBox "Save unsuccesful!"
End If
Unload Me
MainMenuForm.Show
End If
End Sub
请帮忙。我是新手:(
答案 0 :(得分:1)
VALUES
字符串中的逗号分隔项目多于或少于tblScholarProfile
表格中的字段。
VALUES
列表'
字符串分隔符此外,其中一个文本框中的'
会导致错误并且是一个SQL注入漏洞,至少应该{1}}提交的文本中包含replace()
个字符'
''
(2 x '
)逃脱它们。
答案 1 :(得分:0)
您错过了一个较高的逗号txtSchoolID + ",'" + txtSSName
检查了值,您会找到