大家来看看 为什么这段代码无法删除数据记录
<%
Dim ids
ids = Request.QueryString( "id ")
If Not isEmpty(ids) Then
If inStr(ids, ", ")> 0 Then
Dim idArr
idArr=split(ids)
Dim id
For i = 0 To ubound(idarr)
id=cLng(idarr(i))
sql = "DELETE FROM BOOK WHERE ID = ' " & id & " ' "
conn.Execute(sql)
Next
Else
sql = "DELETE FROM BOOK WHERE ID = ' " & ids & " ' "
conn.Execute(sql) //第38行
End If
End If
sql = "DELETE FROM BOOK WHERE ID IN ( " & ids & ") "
conn.Execute(sql)
%>
运行之后,提示:
Microsoft JET Database Engine '80040e07 '
标准表达式中数据类型不匹配。
\bookDelt.asp, line 38
------解决方案-------------------- <%
Dim ids
ids = Request.QueryString( "id ")
If Not isEmpty(ids) Then
If inStr(ids, ", ")> 0 Then
Dim idArr
idArr=split(ids)
Dim id
For i = 0 To ubound(idarr)
id=cLng(idarr(i))
sql = "DELETE FROM BOOK WHERE ID = " & id conn.Execute(sql)
Next
Else
sql = "DELETE FROM BOOK WHERE ID = " & ids 'ID 为整型不用引号
conn.Execute(sql)
End If
End If
sql = "DELETE FROM BOOK WHERE ID IN ( " & ids & ") "
conn.Execute(sql)
%>
------解决方案--------------------sql = "DELETE FROM BOOK WHERE ID = " & id & " "