|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Deleting multiple values
When I try to delete multiple check boxes on this form, I receive the error message below. When only one check box is selected, the delete works correctly.
Error message: Microsoft OLE DB Provider for ODBC Drivers error '80040e07' [Microsoft][ODBC SQL Server Driver][SQL Server]Syntax error converting the varchar value '37, 39' to a column of data type int. /admin/AddDeleteCounty.asp, line 70 Here is the code: 'CREATE DATABASE CONNECTION set objConn=server.createobject("ADODB.Connection") set objRS=server.createobject("ADODB.Recordset") objConn.open Application("ComcastConnection") If request.form("submit") = "Delete" Then StateID = request.form("stateid") for each item in request.form value = Request.Form(item) If Left(Item,6) = "county" Then sqltext="DELETE FROM tblProducerCounties WHERE CountyID='"&value&"'" objConn.Execute(sqltext) sqltext="DELETE FROM tblCounties WHERE CountyID='"&value&"'" objConn.Execute(sqltext) objConn.Close End If Next Message = "1" Else StateID = request.form("stateid") for each item in request.form value = Replace(Request.Form(item), "'", "'") If Left(Item,6) = "county" Then If Request.Form(item) <> "" Then sqltext="INSERT INTO tblCounties (StateID, County) Values ('"&StateID&"','"&value&"')" objConn.Execute(sqltext) End If End If Next Message="2" End If Select Case Message Case 1 %> The County(s) you selected and all corresponding data has/have been successfully deleted. <% Case 2 %> <br> The County(s) has/have successfully been added.<br> <% End Select %> Thank you in advance. |
|
#2
|
||||
|
||||
|
You are going to need to parse a multiple value (which shows up as a string since it contains commas and spaces) and use an OR statement in the WHERE phrase so that multiple CountyID values are matched.
Right now multiple checkboxes return a comma delimited list, from which you need to pickout the numbers using a function like split(), in conjunction with trim() to get rid of spaces to create an array thriugh which you can loop to generate the multiple WHERE statement. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > Deleting multiple values |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|