Forums

This topic is locked

Multi-Insert Form??...Pls Help:(

Posted 29 Apr 2003 21:17:57
1
has voted
29 Apr 2003 21:17:57 Katherine Williams posted:
I went to a page on DMXZone named "Multiple delete using Javascript " at dmxzone.com/ShowDetail.asp?NewsId=3430, and I thought I could somehow change it to an Insert to do what I need...a page that inserts multiple records from one form into one table. My plan is to get the Delete Behavior to work first using the script from that page, then I was going to change it to an Insert page.

But I'm getting an error message (see below). I've also included the page's code, and the query that's generated upon submittal. If someone can help me out with this, or point me in the right direction, it would be greatly appreciated. If anyone knows of a working script or extension (no demos) that I can get a hold of that will do a multiple insert from one form into one DB table, please let me know. Thanks in advance.

KWilliams

I'm getting this error message:

>Microsoft OLE DB Provider for SQL Server error '80040e14'

>Line 1: Incorrect syntax near '(03-005 )'.

>/Employment/app_jobs3C.asp, line 28

This is the query that's generated upon submittal of the form:

>www.douglas-county.com/Employment/app_jobs3C.asp?checkbox=03-005++++&Submit=Add+Job%28s%29[/Q]

And finally, this is the page's code using the JavaScript from DMXZone's page referenced above:

<%@LANGUAGE="JAVASCRIPT"%>
<!--#include file="Connections/strConn.asp" -->
<%
if(String(Request.Querystring("checkbox") != "undefined"{ Command1__varJob_ID = String(Request.Querystring("checkbox");}
%>
<%
// Script enabling multiple delete of records

// If there is no choice, the page "app_jobsconf.asp" is loaded again
// and a message box alerts the user
var emptystring=String(Request.Querystring("checkbox") // The var "emptystring" is used to check the "choice or no choice"
if (emptystring !="undefined" { // If the var "emptystring" contains the user's choice, the datas are deleted

var parenthesisin="("; //var containing the string "("
var parenthesisout=""; //var containing the string ""
//Var "parenthesisin" and "parenthesisout" are added before and after the var "String(Request.Querystring("checkbox")"
if (String(Request.Querystring("checkbox") != "undefined"{ Command1__varJob_ID =parenthesisin + String(Request.Querystring("checkbox")+ parenthesisout;}
var Command1 = Server.CreateObject("ADODB.Command";
Command1.ActiveConnection = MM_strConn_STRING;
// Create a command in "Data Bindings", type="DELETE", SQL="DELETE * FROM Employ_Jobs WHERE Job_ID IN Command1__varJob_ID"
// varJob_ID is a var which value is "Request.Querystring("checkbox""
var Command1 = Server.CreateObject("ADODB.Command";
Command1.ActiveConnection = MM_strConn_STRING;
Command1.CommandText = "DELETE FROM dbo.Employ_Jobs WHERE Job_ID IN '"+ Command1__varJob_ID.replace(/'/g, "''" + "'";
Command1.CommandType = 1;
Command1.CommandTimeout = 0;
Command1.Prepared = true;
Command1.Execute();
Response.Redirect("app_jobsconf.asp"
}

else {%>
<%
var rs_App1A__MMColParam = "Seqno";
if(String(Request.QueryString("id") != "undefined" {
rs_App1A__MMColParam = String(Request.QueryString("id");
}
%>
<%
var rs_App1A__varApp_ID = "%";
if(String(Session("App_ID") != "undefined" {
rs_App1A__varApp_ID = String(Session("App_ID");
}
%>

<%
var rs_App1A__varPassword = "%";
if(String(Session("Password") != "undefined" {
rs_App1A__varPassword = String(Session("Password");
}
%>
<%
var rs_App1A = Server.CreateObject("ADODB.Recordset";
rs_App1A.ActiveConnection = MM_strConn_STRING;
rs_App1A.Source = "SELECT * FROM dbo.Employment_App WHERE App_ID LIKE '"+ rs_App1A__varApp_ID.replace(/'/g, "''" + "' AND Password LIKE '"+ rs_App1A__varPassword.replace(/'/g, "''" + "' AND Seqno = "+ rs_App1A__MMColParam.replace(/'/g, "''" + ""; rs_App1A.CursorType = 0; rs_App1A.CursorLocation = 2; rs_App1A.LockType = 3; rs_App1A.Open(); var rs_App1A_numRows = 0; %>


<% var rs_App1B = Server.CreateObject("ADODB.Recordset";
rs_App1B.ActiveConnection = MM_strConn_STRING;
rs_App1B.Source = "SELECT * FROM Jobs WHERE Job_ID IN (SELECT Job_ID FROM Employ_Jobs) ORDER BY Job_Title ASC"; rs_App1B.CursorType = 0; rs_App1B.CursorLocation = 2; rs_App1B.LockType = 3; rs_App1B.Open(); var rs_App1B_numRows = 0; %>
<%
var Repeat1__numRows = -1;
var Repeat1__index = 0;
rs_App1B_numRows += Repeat1__numRows;
%>

<% if (rs_App1A.EOF) Response.Redirect("www.douglas-county.com/Employment/noaccess.asp")%>
<%
Session("Seqno" = rs_App1A.Fields.Item("Seqno".Value
Session("App_ID" = rs_App1A.Fields.Item("App_ID".Value
Session("Password" = rs_App1A.Fields.Item("Password".Value
%>

<% var MM_paramName = ""; %>

<%
// *** Go To Record and Move To Record: create strings for maintaining URL and Form parameters

// create the list of parameters which should not be maintained
var MM_removeList = "&index="; if (MM_paramName != "" MM_removeList += "&" +
MM_paramName.toLowerCase() + "=";
var MM_keepURL="",MM_keepForm="",MM_keepBoth="",MM_keepNone="";

// add the URL parameters to the MM_keepURL string
for (var items=new Enumerator(Request.QueryString); !items.atEnd();
items.moveNext()) {
var nextItem = "&" + items.item().toLowerCase() + "=";
if (MM_removeList.indexOf(nextItem) == -1) {
MM_keepURL += "&" + items.item() + "=" + Server.URLencode(Request.QueryString(items.item()));
}
}

// add the Form variables to the MM_keepForm string
for (var items=new Enumerator(Request.Form); !items.atEnd();
items.moveNext()) {
var nextItem = "&" + items.item().toLowerCase() + "=";
if (MM_removeList.indexOf(nextItem) == -1) {
MM_keepForm += "&" + items.item() + "=" + Server.URLencode(Request.Form(items.item()));
}
}

// create the Form + URL string and remove the intial '&' from each of the strings MM_keepBoth = MM_keepURL + MM_keepForm; if (MM_keepBoth.length > 0) MM_keepBoth = MM_keepBoth.substring(1); if (MM_keepURL.length > 0) MM_keepURL = MM_keepURL.substring(1); if (MM_keepForm.length > 0) MM_keepForm = MM_keepForm.substring(1); %>

<html>

<head>

<title>Douglas County, Kansas - Online Employment Application-Step 1</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<META NAME="keywords" CONTENT="Douglas County,Douglas County KS,Douglas County Kansas,Douglas,County,Kansas,Government,KS Government,Kansas Government,Stephen A. Douglas,Quantrill,Quantrill's Raid,Lawrence,Lecompton,Baldwin,Baldwin
City,Eudora,Clinton,Jayhawks;KU,Kansas University,University of Kansas,University of KS,Baker University,Haskell,Haskell Indian Nations University,John Baldwin,Amos A. Lawrence,Samuel D. Lecompte,Kanzas Nation.">

<META NAME="description" CONTENT= "Official site for Douglas County, Kansas - Our mission is to provide for the safety and well being of the citizens of Douglas County through the professional and efficient delivery of essential public services in response to the needs of Douglas County citizens.">

<style type="text/css">
<!--
.roll { font-family:"Arial, Helvetica, sans-serif" size="1"; font-style:normal; font-weight:normal; letter-spacing:normal; text-decoration:underline; color:330066; }
A.roll:hover { size="1"; color:red; text-decoration:none;}
-->
INPUT, TEXTAREA {
font-family: "Arial, Helvetica, sans-serif";
padding: 1px;
font-size: 12px;
color: #000000;
background-color: #FFFFFF;
border: inset 2px #660000;
}
</style>
<script language="JavaScript">
<!--

<!-- Begin
if (window != top) top.location.href = location.href;

function NewWindow(mypage, myname, w, h, scroll)
{
var winl = (screen.width - w) / 1.5;
var wint = (screen.height - h) / 1.65;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll
+',resizable'
win = window.open(mypage, myname, winprops)
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

var isNN = (navigator.appName.indexOf("Netscape"!=-1);
function autoTab(input,len, e) {
var keyCode = (isNN) ? e.which : e.keyCode;
var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
if(input.value.length >= len && !containsElement(filter,keyCode)) {
input.value = input.value.slice(0, len);
input.form[(getIndex(input)+1) % input.form.length].focus();
}
function containsElement(arr, ele) {
var found = false, index = 0;
while(!found && index < arr.length)
if(arr[index] == ele)
found = true;
else
index++;
return found;
}
function getIndex(input) {
var index = -1, i = 0, found = false;
while (i < input.form.length && index == -1)
if (input.form[i] == input)index = i;
else i++;
return index;
}
return true;
}
// End -->
//-->
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<form name="form1">

<table width="660" border="0" cellspacing="0" cellpadding="0" bgcolor="#FFFFCC">

<tr>

<td valign="top" height="2">

<table width="100%" border="0" cellspacing="1" cellpadding="1">

<tr>

<td colspan="2" bgcolor="#660000"><font size="2" face="Arial, Helvetica, sans-serif" color="#FFFFFF"><b>Position(s) applying for:</b></font></td>
</tr>

<tr bgcolor="#FFFFCC" valign="top">

<td colspan="2" height="37">

<div align="left">

<% while ((Repeat1__numRows-- != 0) && (!rs_App1B.EOF)) { %>
<input type="checkbox" name="checkbox" value="<%=(rs_App1B.Fields.Item("Job_ID".Value)%>">
<font size="2" face="Arial, Helvetica, sans-serif"><%=(rs_App1B.Fields.Item("Job_Title".Value)%><font size="1"><a class=roll href="app_jobdesc.asp?<%=("Job_ID=" + rs_App1B.Fields.Item("Job_ID".Value)%>">View Details</a></font></font><br>

<%
Repeat1__index++;
rs_App1B.MoveNext();
}
%>
</div>
</td>
</tr>

<tr bgcolor="#FFFFCC">

<td colspan="2">

<p><font size="1" face="Arial, Helvetica, sans-serif" color="#FF0000"><b><img src="Images/bullet2.gif" width="8" height="8">To view details for each position, visit the'View Details' links above.


</b></font>
</p>
</td>
</tr>

<tr>

<td bgcolor="#FFFFCC" valign="bottom" height="2" width="66%"><font size="2" face="Arial, Helvetica, sans-serif">If you have any questions about this form, please contact the Douglas County <a class=roll href=" webmaster <mailto: >
.mailto: ">webmaster</a>.</font></td>
<td bgcolor="#FFFFCC" valign="top" height="2" width="34%" colspan="-1">

<div align="right">

<input type="button" name="Submit2" value="Cancel" onClick="window.close()">
 
<input type="submit" name="Submit" value="Add Job(s)">
</div>
</td>
</tr>

</table>
</td>
</tr>

</table>
</form>
</body>
</html>
<%
rs_App1A.Close();
%>
<%
rs_App1B.Close();
%>
<%
}%>

Reply to this topic