早教吧 育儿知识 作业答案 考试题库 百科 知识分享

急!vb实时错误‘-2147217900(80040e14)’where字句语法错误PrivateSubCommand5Click()Dimwherewhere=""xingming=Text2.Textxingbie=Combo3.Textjiguan=Text22.Textshengri=Text21.Textxueli=Text23.Textzhuanye=Text24.Tex

题目详情
急!vb 实时错误‘-2147217900 (80040e14)’ where字句语法错误Private Sub Command5_Click() Dim where where = "" xingming = Text2.Text xingbie = Combo3.Text jiguan = Text22.Text shengri = Text21.Text xueli = Text23.Text zhuanye = Text24.Text bumen = Text25.Text zhiwu = Text26.Text gongling = Text27.Text '把输入文本框的数据付给变量 If xingming <> "" Then where = where & "AND xingming = '" & xingming & "'" End If If xingbie <> "" Then where = where & "AND xingbie = '" & xingbie & "'" End If If jiguan <> "" Then where = where & "AND jiguan = '" & jiguan & "'" End If If shengri <> "" Then where = where & "AND shengri = '" & shengri & "'" End If If xueli <> "" Then where = where & "AND xueli = '" & xueli & "'" End If If zhuanye <> "" Then where = where & "AND zhuanye = '" & zhuanye & "'" End If If bumen <> "" Then where = where & "AND bumen = '" & bumen & "'" End If If zhiwu <> "" Then where = where & "AND zhiwu = '" & zhiwu & "'" End If If gongling <> "" Then where = where & "AND gongling = '" & gongling & "'" End If '以上代码是为了表示把xingming,xingbie,jiguan等几个变量用布尔表达式来连接,然后把查询数据库的条件之一存在于where 中。 '数据库连接与打开操作 Dim conn As New ADODB.Connection Dim rs As New ADODB.Recordset Dim connstr As String connstr = "provider=microsoft.jet.oledb.4.0;data source=shujuku.mdb" Dim sql As String If where = "" Then sql = "delete * from 员工信息" conn.Open (connstr) rs.Open sql, conn, 3, 3 rs.Close conn.Close '以上代码表示,如果WHERE为空,表示页面上没有输入删除条件,则把表中所有记录都删除 Else where = Mid(shere, 5, Len(where)) '去掉WHERE前面的AND conn.Open (connstr) sql = " delete * from 员工信息 where " & where rs.Open sql, conn, 3, 3 End If MsgBox "记录删除成功!", vbOKOnly, "提示" MSFlexGrid1.Visible = False Command5.Visible = False Exit Sub End Sub 运行提示错误,实时错误‘-2147217900 (80040e14)’ where字句语法错误,错误指向rs.Open sql, conn, 3, 3 总是改不对,请各位高手帮忙!谢谢! 问题补充:这是一个查询出来记录再删除的窗体,查询没问题,就是删除出错,
▼优质解答
答案和解析
else 后面的where = Mid(shere, 5, Len(where)) 改为where = Mid(where, 5, Len(where))就可以了!