doowle
09-15-2002, 11:30 PM
Okay, I know this should be obvious but I have been playing with it for hours and I haven't figured it out yet...maybe a fresh set of eyes will catch it easily.
I am getting the error message
"number of query values and destination fields not the same" referencing line 28 of the following code when I try to update a record:
<!--#include file="source/include/common.asp"-->
<%
' declare variables
strAction = Request("Action")
intAID = Request("AID")
strApplicant = Request("Applicant")
strNextPage = Request("NextPage")
strSearchSQL = "Select AID, Applicant, NextPage from tblSurvey"
If UCase(Request.ServerVariables("REQUEST_METHOD")) = "POST" Then
Select Case strAction
Case "U"
strSQL = "UPDATE tblSurvey " & _
"SET Applicant = '" & formatString(strApplicant, 1) & "', " & _
"NextPage = '" & formatString(strNextPage, 1) & "', " & _
"WHERE AID = " & intAID & ""
Set cmd = objConn.Execute(strSQL)
Set cmd = Nothing
Response.Write("<HTML><BODY onLoad=""alert('Entry updated..!');""></BODY></HTML>")
Case "A"
strSQL = "INSERT INTO tblSurvey (AID, Applicant, NextPage) " & _
"VALUES (" & intAID & ", '" & formatString(strApplicant, 1) & "', " & _
"'" & formatString(strNextPage, 1) & "')"
Set cmd = objConn.Execute(strSQL) <-------------------------------------------- THIS IS LINE 28
Set cmd = Nothing
Response.Write("<HTML><BODY onLoad=""alert('Ran Case A');""></BODY></HTML>")
End Select
strAction = ""
intAID = ""
strApplicant = ""
strNextPage = ""
ElseIf strAction = "U" Then
strSQL = "SELECT * " & _
"FROM tblSurvey " & _
"WHERE AID = " & intAID & ""
Set rsE = objConn.Execute(strSQL)
intAID = rsE("AID")
strApplicant = rsE("Applicant")
strNextPage = rsE("NextPage")
set cmd = objConn.Execute(strSQL)
Set cmd = Nothing
strAction = ""
Response.Write("<HTML><BODY onLoad=""alert('ran strAction U');""></BODY></HTML>")
End If
Set rsC = objConn.Execute(strSearchSQL)
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> Applicants </TITLE>
<script language = "javascript">
function valPage()
{
if(document.frm.Action.value == '')
{
document.frm.Action.value = 'A';
}
document.frm.submit();
}
function valSearch()
{
document.frm.Action.value = 'S';
document.frm.submit();
}
</script>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<table width="100%" height="100%" valign="top" border="0">
<tr>
<td valign="top">
<form name="frm" method="post" action="<%=Request.ServerVariables("SCRIPT_NAME")%>">
<table border="1" cellspacing="0" cellpadding="0">
<tr>
<td align="center" valign="middle"> <table border=0 cellpadding=0 cellspacing=5>
<tr>
<td colspan="2" valign="top"> <P><span class="centerTopTitle">APPLICANT
INFORMATION</span></P>
<hr align=left width="40%"> </td>
</tr>
<tr>
<td align="right" valign="top" nowrap><STRONG>Social Security Number:</STRONG>
</td>
<td width="100%" valign="top">
<INPUT name="AID" type="text" id="AID" value="<%=intAID%>" size="25" maxlength="25">
</td>
</tr>
<tr>
<td height="24" align="right" valign="top" nowrap><STRONG>Last Name:</STRONG></td>
<td valign="top">
<INPUT name="Applicant" type="text" id="Applicant" value="<%=strApplicant%>" size="35" maxlength="35">
</td>
</tr>
<tr>
<td align="right" valign="top" nowrap><STRONG>Next Page:</STRONG>
</td>
<td valign="top">
<INPUT name="NextPage" type="text" id="NextPage" value="<%=strNextPage%>" size="35" maxlength="35">
</td>
</tr>
<tr>
<td colspan="2" align="right">
<input type="hidden" name="Action" value="<%=strAction%>">
<input type="hidden" name="AID" value="<%=Request("AID")%>">
<input type="button" name="btnSubmit" value="Submit" onClick="valPage();">
<input type="button" name="btnClear" value="Clear" onClick="location.replace('<%=Request.ServerVariables("SCRIPT_NAME")%>');">
</td>
</tr>
</table>
</td>
</tr>
</table>
<b>Current Applicants in Table</b></p>
<hr align="left" width="200">
</p>
<table border="0" cellspacing="5" cellpadding="0">
<tr>
<td nowrap> </td>
<td nowrap><u><b>Social Security Number</b></u></td>
<td nowrap><u><b>Last Name</b></u></td>
<td nowrap><u><b>Next Page</b></u></td>
</tr>
<%
If Not rsC.EOF Then
While Not rsC.EOF
%>
<tr>
<td nowrap><a href="?Action=U&AID=<%=rsC("AID")%>">edit</a></td>
<td nowrap><%=rsC("AID")%></td>
<td nowrap><%=rsC("Applicant")%></td>
<td nowrap><%=rsC("NextPage")%></td>
</tr>
<%
rsC.MoveNext
WEND
Else
Response.Write("<tr><td colspan=""5"">No records found...</td></tr>")
End If
%>
</form>
</table>
</td>
</tr>
</table>
</body>
</html>
<%
' cleanup objects
Set rsC = Nothing
Set rsE = Nothing
Set objConn = Nothing
%>
Count and count as I can, I still don't see where they are not equal. Do you?
I am getting the error message
"number of query values and destination fields not the same" referencing line 28 of the following code when I try to update a record:
<!--#include file="source/include/common.asp"-->
<%
' declare variables
strAction = Request("Action")
intAID = Request("AID")
strApplicant = Request("Applicant")
strNextPage = Request("NextPage")
strSearchSQL = "Select AID, Applicant, NextPage from tblSurvey"
If UCase(Request.ServerVariables("REQUEST_METHOD")) = "POST" Then
Select Case strAction
Case "U"
strSQL = "UPDATE tblSurvey " & _
"SET Applicant = '" & formatString(strApplicant, 1) & "', " & _
"NextPage = '" & formatString(strNextPage, 1) & "', " & _
"WHERE AID = " & intAID & ""
Set cmd = objConn.Execute(strSQL)
Set cmd = Nothing
Response.Write("<HTML><BODY onLoad=""alert('Entry updated..!');""></BODY></HTML>")
Case "A"
strSQL = "INSERT INTO tblSurvey (AID, Applicant, NextPage) " & _
"VALUES (" & intAID & ", '" & formatString(strApplicant, 1) & "', " & _
"'" & formatString(strNextPage, 1) & "')"
Set cmd = objConn.Execute(strSQL) <-------------------------------------------- THIS IS LINE 28
Set cmd = Nothing
Response.Write("<HTML><BODY onLoad=""alert('Ran Case A');""></BODY></HTML>")
End Select
strAction = ""
intAID = ""
strApplicant = ""
strNextPage = ""
ElseIf strAction = "U" Then
strSQL = "SELECT * " & _
"FROM tblSurvey " & _
"WHERE AID = " & intAID & ""
Set rsE = objConn.Execute(strSQL)
intAID = rsE("AID")
strApplicant = rsE("Applicant")
strNextPage = rsE("NextPage")
set cmd = objConn.Execute(strSQL)
Set cmd = Nothing
strAction = ""
Response.Write("<HTML><BODY onLoad=""alert('ran strAction U');""></BODY></HTML>")
End If
Set rsC = objConn.Execute(strSearchSQL)
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> Applicants </TITLE>
<script language = "javascript">
function valPage()
{
if(document.frm.Action.value == '')
{
document.frm.Action.value = 'A';
}
document.frm.submit();
}
function valSearch()
{
document.frm.Action.value = 'S';
document.frm.submit();
}
</script>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<table width="100%" height="100%" valign="top" border="0">
<tr>
<td valign="top">
<form name="frm" method="post" action="<%=Request.ServerVariables("SCRIPT_NAME")%>">
<table border="1" cellspacing="0" cellpadding="0">
<tr>
<td align="center" valign="middle"> <table border=0 cellpadding=0 cellspacing=5>
<tr>
<td colspan="2" valign="top"> <P><span class="centerTopTitle">APPLICANT
INFORMATION</span></P>
<hr align=left width="40%"> </td>
</tr>
<tr>
<td align="right" valign="top" nowrap><STRONG>Social Security Number:</STRONG>
</td>
<td width="100%" valign="top">
<INPUT name="AID" type="text" id="AID" value="<%=intAID%>" size="25" maxlength="25">
</td>
</tr>
<tr>
<td height="24" align="right" valign="top" nowrap><STRONG>Last Name:</STRONG></td>
<td valign="top">
<INPUT name="Applicant" type="text" id="Applicant" value="<%=strApplicant%>" size="35" maxlength="35">
</td>
</tr>
<tr>
<td align="right" valign="top" nowrap><STRONG>Next Page:</STRONG>
</td>
<td valign="top">
<INPUT name="NextPage" type="text" id="NextPage" value="<%=strNextPage%>" size="35" maxlength="35">
</td>
</tr>
<tr>
<td colspan="2" align="right">
<input type="hidden" name="Action" value="<%=strAction%>">
<input type="hidden" name="AID" value="<%=Request("AID")%>">
<input type="button" name="btnSubmit" value="Submit" onClick="valPage();">
<input type="button" name="btnClear" value="Clear" onClick="location.replace('<%=Request.ServerVariables("SCRIPT_NAME")%>');">
</td>
</tr>
</table>
</td>
</tr>
</table>
<b>Current Applicants in Table</b></p>
<hr align="left" width="200">
</p>
<table border="0" cellspacing="5" cellpadding="0">
<tr>
<td nowrap> </td>
<td nowrap><u><b>Social Security Number</b></u></td>
<td nowrap><u><b>Last Name</b></u></td>
<td nowrap><u><b>Next Page</b></u></td>
</tr>
<%
If Not rsC.EOF Then
While Not rsC.EOF
%>
<tr>
<td nowrap><a href="?Action=U&AID=<%=rsC("AID")%>">edit</a></td>
<td nowrap><%=rsC("AID")%></td>
<td nowrap><%=rsC("Applicant")%></td>
<td nowrap><%=rsC("NextPage")%></td>
</tr>
<%
rsC.MoveNext
WEND
Else
Response.Write("<tr><td colspan=""5"">No records found...</td></tr>")
End If
%>
</form>
</table>
</td>
</tr>
</table>
</body>
</html>
<%
' cleanup objects
Set rsC = Nothing
Set rsE = Nothing
Set objConn = Nothing
%>
Count and count as I can, I still don't see where they are not equal. Do you?