cheishing
02-12-2005, 09:18 PM
I'm trying to delete multiple records from a database by selecting from the checkbox. but there seems to be some error.
delUser.asp
--------------------------------------------------------------------
<%@LANGUAGE="VBSCRIPT"%><!--include virtual=/cmd/checklogin.asp-->
<!--include virtual=/cmd/connectdb.asp-->
<!--include virtual=/checklogin.asp-->
<!--#include virtual=/connectdb.asp-->
<%
Dim m_title, m_description
m_title = "Delete User"
m_description = "Use this page to delete User(s). TO Delete User(s), Check the Checkered Box and click the delete button to delete.."
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Mailing List Database - <%=m_title%></title>
<link href="../cmd.css" type="text/css" rel="stylesheet">
</head>
<body background="../images/detailsbg.gif" leftMargin="0" topMargin="0" marginwidth="0" marginheight="0">
<!--#include file=../header.htm-->
<form action="thankyou.asp" method="get" name="form1">
<table style="border-color:purple;border-style:solid; border-width:1;" border="0" align="center" cellpadding="5" cellspacing="1" width="100%">
<tr align="center">
<td width="6%"><strong>UserID</strong></td>
<td width="15%"><strong>UserName</strong></td>
<td width="17%"><strong>Designation</strong></td>
<td width="12%"><strong>Email address</strong></td>
<td width="13%"><strong>Role</strong></td>
<td width="14%"><strong>School </strong></td>
<td width="17%"><strong>SchoolCode</strong></td>
</tr>
<%
mySQL="SELECT m_userid, m_username, m_designation, m_school, m_schoolcode, m_emailaddress, m_role FROM CUsers"
set rsView = o_db.execute(mySQL)
%>
<% DO WHILE NOT rsView.EOF %>
<tr>
<td><div align="center">
<input name="cbDel" align="middle" type="checkbox" id="cbDel" value="<%=(rsView.Fields.Item("m_userid").Value)%>"></div></td>
<td><div align="center"><%=(rsView.Fields.Item("m_username").Value)%></div></td>
<td><div align="center"><%=(rsView.Fields.Item("m_designation").Value)%></div></td>
<td><div align="center"><%=(rsView.Fields.Item("m_emailaddress").Value)%></div></td>
<td><div align="center"><%=(rsView.Fields.Item("m_role").Value)%></div></td>
<td><div align="center"><%=(rsView.Fields.Item("m_school").Value)%></div></td>
<td><div align="center"><%=(rsView.Fields.Item("m_schoolcode").Value)%></div></td>
<%rsView.MoveNext()
LOOP
%>
</tr>
<tr>
<td colspan="8"> <input name="Delete" type="submit" value="Delete" ></td>
</tr>
</table>
</form>
<p>
</body>
</html>
===========================================================
thankyou.asp
-----------------------------------------------------------------
<%@LANGUAGE="VBSCRIPT"%><!--include virtual=/cmd/checklogin.asp-->
<!--include virtual=/cmd/connectdb.asp-->
<!--include virtual=/checklogin.asp-->
<!--#include virtual=/connectdb.asp-->
<%
Dim strSelection, arrSelection
strSelection = Request.QueryString("cbDel")
'Convert strSelection To a string
strSelection = CStr(strSelection)
arrSelection = Split(strSelection,",") '| This will retuen an array of sub-strings.
Dim i
Dim strQuery, objConn
strQuery = "DELETE FROM CUsers WHERE "
For i = 0 To UBound(arrSelection)
If i > 0 Then
strQuery = strQuery & "m_userid = " & arrSelection(i)
Response.write(arrSelection(i))
Else
strQuery = strQuery & "m_userid = " & arrSelection(i)
End If
Next
set objConn = o_db.execute(strQuery)
%>
<%
Dim m_title, m_description
m_title = "Delete User"
m_description = "Use this page to delete User(s). TO Delete User(s), Check the Checkered Box and click the delete button to delete.."
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Mailing List Database - <%=m_title%></title>
<link href="../cmd.css" type="text/css" rel="stylesheet">
<style type="text/css">
<!--
.style1 {color: #FF0000}
-->
</style>
</head>
<body background="../images/detailsbg.gif" leftMargin="0" topMargin="0" marginwidth="0" marginheight="0">
<!--#include file=../header.htm--><p>
<body>
<p class="style1">THe User(s) has been Successfully Deleted.</p>
<p class="style1"><% response.Write(strQuery) %></p>
<p><a href="delUser.asp">back</a> </p>
</div>
</body>
</html>
===================================================
okie.. now the problem is i keep on getting this error:
Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near 'WHERE'.
/User/TMPoq3mqbtvvs.asp, line 39
can someone help me with it. thanks.
delUser.asp
--------------------------------------------------------------------
<%@LANGUAGE="VBSCRIPT"%><!--include virtual=/cmd/checklogin.asp-->
<!--include virtual=/cmd/connectdb.asp-->
<!--include virtual=/checklogin.asp-->
<!--#include virtual=/connectdb.asp-->
<%
Dim m_title, m_description
m_title = "Delete User"
m_description = "Use this page to delete User(s). TO Delete User(s), Check the Checkered Box and click the delete button to delete.."
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Mailing List Database - <%=m_title%></title>
<link href="../cmd.css" type="text/css" rel="stylesheet">
</head>
<body background="../images/detailsbg.gif" leftMargin="0" topMargin="0" marginwidth="0" marginheight="0">
<!--#include file=../header.htm-->
<form action="thankyou.asp" method="get" name="form1">
<table style="border-color:purple;border-style:solid; border-width:1;" border="0" align="center" cellpadding="5" cellspacing="1" width="100%">
<tr align="center">
<td width="6%"><strong>UserID</strong></td>
<td width="15%"><strong>UserName</strong></td>
<td width="17%"><strong>Designation</strong></td>
<td width="12%"><strong>Email address</strong></td>
<td width="13%"><strong>Role</strong></td>
<td width="14%"><strong>School </strong></td>
<td width="17%"><strong>SchoolCode</strong></td>
</tr>
<%
mySQL="SELECT m_userid, m_username, m_designation, m_school, m_schoolcode, m_emailaddress, m_role FROM CUsers"
set rsView = o_db.execute(mySQL)
%>
<% DO WHILE NOT rsView.EOF %>
<tr>
<td><div align="center">
<input name="cbDel" align="middle" type="checkbox" id="cbDel" value="<%=(rsView.Fields.Item("m_userid").Value)%>"></div></td>
<td><div align="center"><%=(rsView.Fields.Item("m_username").Value)%></div></td>
<td><div align="center"><%=(rsView.Fields.Item("m_designation").Value)%></div></td>
<td><div align="center"><%=(rsView.Fields.Item("m_emailaddress").Value)%></div></td>
<td><div align="center"><%=(rsView.Fields.Item("m_role").Value)%></div></td>
<td><div align="center"><%=(rsView.Fields.Item("m_school").Value)%></div></td>
<td><div align="center"><%=(rsView.Fields.Item("m_schoolcode").Value)%></div></td>
<%rsView.MoveNext()
LOOP
%>
</tr>
<tr>
<td colspan="8"> <input name="Delete" type="submit" value="Delete" ></td>
</tr>
</table>
</form>
<p>
</body>
</html>
===========================================================
thankyou.asp
-----------------------------------------------------------------
<%@LANGUAGE="VBSCRIPT"%><!--include virtual=/cmd/checklogin.asp-->
<!--include virtual=/cmd/connectdb.asp-->
<!--include virtual=/checklogin.asp-->
<!--#include virtual=/connectdb.asp-->
<%
Dim strSelection, arrSelection
strSelection = Request.QueryString("cbDel")
'Convert strSelection To a string
strSelection = CStr(strSelection)
arrSelection = Split(strSelection,",") '| This will retuen an array of sub-strings.
Dim i
Dim strQuery, objConn
strQuery = "DELETE FROM CUsers WHERE "
For i = 0 To UBound(arrSelection)
If i > 0 Then
strQuery = strQuery & "m_userid = " & arrSelection(i)
Response.write(arrSelection(i))
Else
strQuery = strQuery & "m_userid = " & arrSelection(i)
End If
Next
set objConn = o_db.execute(strQuery)
%>
<%
Dim m_title, m_description
m_title = "Delete User"
m_description = "Use this page to delete User(s). TO Delete User(s), Check the Checkered Box and click the delete button to delete.."
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Mailing List Database - <%=m_title%></title>
<link href="../cmd.css" type="text/css" rel="stylesheet">
<style type="text/css">
<!--
.style1 {color: #FF0000}
-->
</style>
</head>
<body background="../images/detailsbg.gif" leftMargin="0" topMargin="0" marginwidth="0" marginheight="0">
<!--#include file=../header.htm--><p>
<body>
<p class="style1">THe User(s) has been Successfully Deleted.</p>
<p class="style1"><% response.Write(strQuery) %></p>
<p><a href="delUser.asp">back</a> </p>
</div>
</body>
</html>
===================================================
okie.. now the problem is i keep on getting this error:
Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near 'WHERE'.
/User/TMPoq3mqbtvvs.asp, line 39
can someone help me with it. thanks.